1

Suppose I have this HTML →

 <div class="author-category">
      <ul>
          <li><a href="">CATEGORY 1</a></li>
          <li><a href="">CATEGORY 2</a></li>
          <li><a href="">CATEGORY 3</a></li>
          <li><a href="">CATEGORY 4</a></li>
          <li><a href="">CATEGORY 5</a></li>
      </ul>
 </div>

I tried this code, but this is code is not able to pull any categories →

<ul> <?php foreach($categories as $category) : ?> <li> <a href="<?php echo get_category_link( $category->ID ); ?>" title="<?php echo $category->name ?>"><?php echo $category->name ?></a> </li> <?php endforeach; ?> </ul>

Now I want to run a loop so that I can fetch categories, but the constraint is that the categories should be fetched only for the author of that Post.

  • Take a look at this post: wordpress.stackexchange.com/questions/81599/… – Dave Romsey May 10 '17 at 18:48
  • With the help of that post I can pull categories, but how can we put restraint of an author. I mean I just want to pull categories for that post only. – The WP Novice May 10 '17 at 19:09
  • Sure, but now you've changed what your original question stated. :-). Please update your question and add the code your're working with. – Dave Romsey May 10 '17 at 19:15
  • Sir, I have updated and done that. – The WP Novice May 10 '17 at 19:18
  • You'll need to use the code from the answer I linked to. – Dave Romsey May 10 '17 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.