WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Taxonomy and Author Post issue (6 posts)

  1. ddeuster
    Member
    Posted 1 year ago #

    On our site we have a section that contains articles of our online publication written by several different authors. Knowing we did not want to give every one of those contributors an account, we opted to included a taxonomy called 'writers. On our page posts we would like to have our main editor's name appear as the_author_post unless there is a taxonomy checked. Below is the code we currently are using.

    <?php if(taxonomy_exists('writers')){echo get_the_term_list($post->ID, 'writers');} else {
              ?>
    <?php the_author_posts_link(); } ?>

    Unfortunately the_post_author will not show up on pages where there is not a writer assigned to the post through the taxonomy. What are we missing in our if/else code.

    Thanks in Advance.

  2. converting2wp
    Member
    Posted 1 year ago #

    Are you sure the call to the_author_posts_link is inside the loop? You may have to share more of your template file for us to help figure out what's gone wrong.

  3. converting2wp
    Member
    Posted 1 year ago #

    Okay. Sorry. I've taken my testing a bit further and am running into the same problem.

  4. converting2wp
    Member
    Posted 1 year ago #

    Doh.

    Your first condition is always true. The *taxonomy* "exists" irrespective of whether or not the particular post has a writer associated with it.

    Try this condition instead:

    if (has_term('','writers')) {

  5. ddeuster
    Member
    Posted 1 year ago #

    Tried but with no success. It seems to be passing looking for writer and going strait to the_author_post.

  6. ddeuster
    Member
    Posted 1 year ago #

    Nevermind. I had misread what you had typed. Thanks so much for the solution.

Topic Closed

This topic has been closed to new replies.

About this Topic