php - How do I show only one specific post with comments and author box on the homepage in Wordpress? -
i want show full post comments , author box on home page if actual link post clicked. set canonical on actual post point home page seo purposes.
i've seen code out there, far nothing matches exact needs.
i want display 1 wordpress post on homepage comments , author box below post. , want able specify post 1 gets displayed on homepage. (which post id#)
to add this, need rel="author" visible in header section. i'm using wordpress seo yoast , have selected not show rel="author" pages. , code out there i've tried shows single post on home page treats if page instead of post, therefore removing rel="author" head area.
please not reply how set number of posts in reading tab or how set static page. know that. won't work needs.
in summary, when go home page see article wrote along comments , author box below , rel="author" in header.
your best bet set homepage static page, , build custom template page. in editor, create custom field allows select blog post feature (look advanced custom fields plugin easy custom fields), grab custom field value, , use build either wp_query, or call various bits of information using id of post. trickiest part getting the_content() id. here's how can that:
add function functions.php file:
function get_the_content_by_id($post_id) { $page_data = get_page($post_id); if ($page_data) { return $page_data->post_content; }else{ return false; } }
call function in page template this:
echo get_the_content_by_id([insert desired post id here]);
if make php file in theme directory called front-page.php, automatically appear template static home page.
now far rel="author" thing, don't know that, unfortunately cannot that.
also, i'm unsure why code losing it's formatting here.
Comments
Post a Comment