简体   繁体   中英

Showing author box on post page wordpress

i am just a beginner in word-press as well in PHP.I am trying to display author information along with his picture in the post and have successfully able to fetch all the data from gravatar.com and able to display it on the right hand side bar successfully.

Currently this box is coming through out the website, but my requirement is that it should only be displayed when reader is on the post detail page. As per my little knowledge of word-press, i kw that each post will going to relate to some category. How can i able to show the author box to only post detail page and hide it from all other places.Any help in this regard will be much helpful

just to edit i have added following code

<?php  $category_ids = remove_element(get_all_category_ids(),'274');
     if (in_category($category_ids)) { ?>

this code is not working but if i pass a single category id to in_category() function like

 <?php  
     if (in_category('8')) { ?>

if block is working fine.

Edit sidebar.php and use the is_single conditional tag to make the code show up only if a single post is displayed.

Wrap your code in

<?php  if(is_single()){
// your code goes here! 
}?>

If you want to show something on the post detail page. You've to mess with single.php, it is the main source. However if you want to show some text from right sidebar only on Post Pages you can do this.

if(is_single()){
// do this when viewing single post details
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM