简体   繁体   English

在帖子WordPress上显示作者框

[英]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. 我只是PHP中的单词压制初学者,我试图在帖子中显示作者信息以及他的图片,并成功地能够从gravatar.com提取所有数据并能够在右侧显示侧栏成功。

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 此代码无法正常工作,但如果我将单个类别ID传递给in_category()函数,例如

 <?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. 编辑sidebar.php,并使用is_single条件标签使代码仅在显示单个帖子时显示。

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. 您必须弄乱single.php,这是主要来源。 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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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