This question was suggested to me by How can I sell my text book to my students in e-book format? which asked about the practicalities, but attracted many comments about the ethics.  So this question is to ask about the ethics directly.

Suppose I have written and published a textbook, and I want to use it as the text for a course I am teaching.  I receive royalties from each copy of my book that is sold, so if my students are required to buy my textbook for the course, I will make some money.  Is it ethical to do so?

Well-reasoned opinions would be useful answers, but even more useful would be pointers to institutional policies, professional codes of ethics, etc, that address this issue.

Of course, there are many ways to avoid profiting from the sale of my book to my students.  If my contract with my publisher allows it, I could distribute PDFs to my students, or have the university bookstore print out copies and sell them at cost.  Another approach I've heard of is to compute how much I earn in royalties on each copy, and refund that amount from my pocket to each student who buys a copy.  Or, use my royalty earnings to buy pizza for the class.  Certainly these are nice gestures, but I would like opinions on whether they are ethically required.

Edit: To address some questions that have arisen in the comments:


This question is hypothetical.  I haven't published any textbooks myself and have no immediate plans to do so.  In any case, my personal preference would be to make the book available to students for free, if at all possible.  So I've phrased this question in the first person for rhetorical convenience only.
I had intended the question to be only about the potential financial conflict of interest that could arise if I make money by assigning my own book.  Some of the answers feel that it is improper for me to assign my own textbook at all, whether I make money or not, but I don't think this point of view is prevalent within the academic community.  If it happens that my book (as a pithy but now-deleted comment put it) "blows", I think most would agree that my decision to assign it is pedagogically unfortunate, but not unethical.  
I don't literally mean that students would be required to buy the book, only that they'd be expected to have it.  I might assign readings or homework problems from the book, so that the student needs access to the book in order to do them, but they could certainly achieve this by getting a used copy or borrowing from a friend.  But probably most students would buy new copies anyway, since that is the most convenient way.



Question: Wordpress - Custom taxonomy page of custom post type listing by terms
Answer: It's not necessary to transform the object to an array, you can perfectly work with the object without too much hassle. What is curious (at least for me), is that you get something like this:

  Array
  (
      [0] =&gt; stdClass Object
          (
              [term_id] =&gt; 7
              [name] =&gt; Magister comunicaciones aplicadas
              [slug] =&gt; magister-comunicaciones-aplicadas
              [term_group] =&gt; 0
              [term_taxonomy_id] =&gt; 7
              [taxonomy] =&gt; linea-de-estudio
              [description] =&gt; 
              [parent] =&gt; 0
              [count] =&gt; 4
          )

      [1] =&gt; stdClass Object
          (
               [term_id] =&gt; 8
               [name] =&gt; Engagement marketing
               [slug] =&gt; engagement-marketing
               [term_group] =&gt; 0
               [term_taxonomy_id] =&gt; 8
               [taxonomy] =&gt; linea-de-estudio
               [description] =&gt; 
               [parent] =&gt; 0
               [count] =&gt; 5
          )
  )


It's basically, an array of objects, so you've to treat them that way. For example if I want the name of the the first one:

$myterms = get_terms('taxonomy-name', 'orderby=none&amp;hide_empty');    
echo  $myterms[0]-&gt;name;


If you need to iterate through the elements, you still can use foreach();.

foreach ($myterms as $term) { ?&gt;
    &lt;li&gt;&lt;a href="&lt;?php echo $term-&gt;slug; ?&gt;"&gt;&lt;?php echo $term-&gt;name; ?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php
} ?&gt;


That way you can post the articles from your taxonomy.

For the custom post types, you'll have to create a loop like this:

$args = array(
    'post_type' =&gt; 'post-type-name',
    'taxonomy' =&gt; 'term'
    //for example
    //'resources' =&gt; 'videos'
);

//  assigning variables to the loop
global $wp_query;
$wp_query = new WP_Query($args);

// starting loop
while ($wp_query-&gt;have_posts()) : $wp_query-&gt;the_post();

the_title();
blabla....

endwhile;


Then you can create multiple loops each of one for each taxonomy/term :).

If you want to get even more fancy (don't want to repeat yourself a hundred times) you can include the second loop inside the first one and assign variables to the taxonomy (resources ie) and the terms it has (videos) (from your example only the last one). The idea is that you would have a normal (typical) wordpress loop restricted to the custom post-type and each one of the terms.

foreach ($myterms as $term) : ?&gt;
    &lt;li&gt;&lt;a href="&lt;?php echo $term-&gt;slug; ?&gt;"&gt;&lt;?php echo $term-&gt;name; ?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php

        $term_name = $term-&gt;slug;

        $args = array(
        'post_type' =&gt; 'post-type-name',
        'taxonomy' =&gt; "$term_name"
        );

   //  assigning variables to the loop
   global $wp_query;
   $wp_query = new WP_Query($args);

   // starting loop posting only
   while ($wp_query-&gt;have_posts()) : $wp_query-&gt;the_post();

   the_title();
   blabla....

   endwhile;

endforeach; ?&gt;


Obviously you can do the inverse thing too, create the normal loop for a single-template custom type (it's looks like you have only one), and inside includes all the custom terms.

Not very elegant, but that's the best way I can came up with it :P. Hope that someone can understand this, sounds confusing. 

Maybe could it be possible with some callback function?.