Title: Conditional tag question
Last modified: August 19, 2016

---

# Conditional tag question

 *  Resolved [Dan Petty](https://wordpress.org/support/users/dpetty/)
 * (@dpetty)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/)
 * Hi,
 * I couldn’t find anything that quite related to this on the forums, and I am fairly
   limited in my coding knowledge. I’m looking to set up some sort of condition 
   such that if the author of a post is “admin” then a custom field I have designated
   as “hpbyline” is displayed. Otherwise, the designated author is displayed.
 * I have something close already, that works this way: If the author is “admin”,
   then NOTHING is displayed. How would I modify it so that
    <?php echo c2c_get_custom(‘
   hpbyline’); ?> is displayed instead?
 * Thanks for the help!
 *     ```
       <?php
                                      $auth = get_the_author();
                                  if ($auth != 'admin') :
                                  ?>
                         <div class="byline">
                                  By <?php if(function_exists('coauthors_posts_links'))
                                          coauthors_posts_links();
                                  else
                                     the_author_posts_link(); ?>
                         </div>
   
                         <div class="bytitle">
                                   <?php echo c2c_get_custom('Bytitle'); ?>
                         </div>
                                   <?php endif; ?>
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/#post-1016849)
 *     ```
       <div class="byline">
       <?php
       $auth = get_the_author();
       if ($auth == 'admin') { ?>
         echo c2c_get_custom('hpbyline');
       } else {
         the_author_posts_link();
       ?>
       </div>
   
       <div class="bytitle">
           <?php echo c2c_get_custom('Bytitle'); ?>
       </div>
       ```
   
 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/#post-1016850)
 * correction:
 *     ```
       <div class="byline">
       <?php
       $auth = get_the_author();
       if ($auth == 'admin') {
         echo c2c_get_custom('hpbyline');
       } else {
         the_author_posts_link();
       ?>
       </div>
   
       <div class="bytitle">
           <?php echo c2c_get_custom('Bytitle'); ?>
       </div>
       ```
   
 *  Thread Starter [Dan Petty](https://wordpress.org/support/users/dpetty/)
 * (@dpetty)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/#post-1016864)
 * Thanks for the reply, stvwif, but it doesn’t seem to be working. Here’s what 
   it spits back.
 *     ```
       Parse error: syntax error, unexpected T_ENDWHILE in /home1/thecolm1/public_html/wp-content/themes/revolution_news-21/archive.php on line 44
       ```
   
 * I was also wondering whether it was possible to integrate the “Co-authors” plugin
   I have activated into your solution. Essentially, if the post author IS NOT “
   admin” go through these commands (below). There are a lot of if/else statements
   in this, and I don’t know how to properly code it.
 *     ```
       <?php if(function_exists('coauthors_posts_links'))
                                          coauthors_posts_links();
                                  else
                                     the_author_posts_link(); ?>
       ```
   
 *  Thread Starter [Dan Petty](https://wordpress.org/support/users/dpetty/)
 * (@dpetty)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/#post-1016967)
 * Can anyone build on stvwif’s response?
 *  [stvwlf](https://wordpress.org/support/users/stvwlf/)
 * (@stvwlf)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/#post-1017011)
 *     ```
       <?php
       if (!$auth == 'admin') {
          if(function_exists('coauthors_posts_links')) {
             coauthors_posts_links();
          } else {
             the_author_posts_link();
          }
       } ?>
       ```
   
 *  Thread Starter [Dan Petty](https://wordpress.org/support/users/dpetty/)
 * (@dpetty)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/#post-1017058)
 * Here’s the final solution, after some messing around with code. I’ve tested and
   it works. Thanks for the help, stvwlf.
 *     ```
       <?php
       $auth = get_the_author();
       if ($auth == 'admin') {
         echo c2c_get_custom('hpbyline');
       } else {
             if(function_exists('coauthors_posts_links')) {
                  coauthors_posts_links();
             } else {
                  the_author_posts_link();
            }
          }
       ?>
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Conditional tag question’ is closed to new replies.

## Tags

 * [conditional tags](https://wordpress.org/support/topic-tag/conditional-tags/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [Dan Petty](https://wordpress.org/support/users/dpetty/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-tag-question/#post-1017058)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
