Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is my code to retrieve the related posts from the same author in Wordpress:

<?php function get_related_author_posts() {
   global $authordata, $post;

   $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 10, 'category__not_in' => get_option('my_cat_ids') ) );
   foreach ( $authors_posts as $authors_post ) {
   $output .= '<div class="related-games block"><a class="hover_play_small" href="' . get_permalink( $authors_post->ID ) . '">' .get_the_post_thumbnail($authors_post->ID, 'related-thumb') . '</a></div>';
   return $output;

In the code above I want to exclude all posts from a specific category by an admin option but it seams the category__not_in accepts only IDs. That's because if I use 'category__not_in' => 6 instead of 'category__not_in' => get_option('my_cat_ids') it works fine. The problem is I really need to use the get_option function.

How do you think you could do this work?

Later edit: I apologize, it was my mistake that I wrote in admin option the category name instead of its id. However a code would be helpful to read both variants, like:

if admin option the category is an id
display its id
if in admin option category is a name
display its name


share|improve this question
The answer should be the same as the answer to your other question : wordpress.stackexchange.com/q/102400/21376 –  s_ha_dum Jun 9 '13 at 14:35
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.