• Resolved theApe

    (@theape)


    How would I make a conditional statement for an authors specific content to show one thing or another depending on whether that certain author has posted to a specific category. For example…

    In the post meta of any post written by ‘Jane’. The statement needs to be conditional on whether she has ever posted to a certain category.

    if
    Post count 1+ in cat X ->[Jane has at some point in time posted to X category]
    else
    Post count 0 in cat X ->[Jane has never posted to X category]
    end

    Any help would be appreciated I’ve not be able to find a conditional tag for whether a category has posts or not in the codex.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter theApe

    (@theape)

    Alternatively, how can I call an authors ID in author archive if they have no posts.

    In a loop you could use:

    <?php
    $userposts = get_posts('cat=3&showposts=-1&author='.$post->post_author);
    $count=count($userposts);
    if ($count) {
    echo '<p>author has this number of posts in category 3: ' .$count . '</p>';
    } else {
    echo '<p>author has no posts in category 3</p>';
    }
    ?>
    Thread Starter theApe

    (@theape)

    $userposts = get_posts('cat=3&showposts=-1&author='.$post->post_author);
    $count=count($userposts);
    if ($count)

    Thank you! That was exactly what I needed!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional on author with no posts in cat…’ is closed to new replies.