0

I have this part in my index-meta.php file :

                        <ul>

                            <li class="Source"><a>source:</a></li>
                              <ul class="Source-Link">
                                <li><a href="<?php echo get_post_meta($post->ID, 'source-link', true); ?>" target="_blank"><?php echo get_post_meta($post->ID, 'source', true); ?></a></li>
                              </ul>

                        </ul>

this'll show the source of my posts based on the custom fields I've made, and I just want them to show in the content-single.php file, I mean the single posts page. but they also showing in front page (index.php, content.php), I dont' want that. what conditional can I use and how? please help me with this cause I'm pretty weak in php and wp...

1
  • hmmm.... maybe I've missed it but I am not familiar with an index-meta.php template. What is that and how are you using it?
    – s_ha_dum
    Commented Nov 3, 2013 at 15:45

1 Answer 1

0

You can use is_single() in a conditional statement.

<?php if( is_single() ){ ?>
  <ul>
    <li class="Source"><a>source:</a></li>
       <ul class="Source-Link">
           <li><a href="<?php echo get_post_meta($post->ID, 'source-link', true); ?>" target="_blank"><?php echo get_post_meta($post->ID, 'source', true); ?></a></li>
       </ul>
    </li>
  </ul>
<?php }?>

Be aware though that this will appear on any single page, meaning a single post page and a single page.

http://codex.wordpress.org/Function_Reference/is_singular

1
  • THANK YOU VERY MUCH BRO. Your answer was really helpful JUST WHAT I NEEDED THANKS A LOT AGAIN
    – Komeyl94
    Commented Nov 3, 2013 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.