admin管理员组文章数量:1252691
I can't believe I did not find the right function for this: I just want to retrieve the blog index url from a template.
My homepage is a static page. I am not looking for bloginfo('url') because it gives me my root url (/). I am looking for mysite/Blog
I am thinking about getting it via get_permalink($mypageid) but it is a bit dirty.
I can't believe I did not find the right function for this: I just want to retrieve the blog index url from a template.
My homepage is a static page. I am not looking for bloginfo('url') because it gives me my root url (/). I am looking for mysite/Blog
I am thinking about getting it via get_permalink($mypageid) but it is a bit dirty.
Share Improve this question asked Jun 6, 2013 at 8:44 Paul EtienneyPaul Etienney 1154 bronze badges3 Answers
Reset to default 4if you are referring to the 'posts page' as set under dashboard - settings - reading:
<?php
if( get_option( 'page_for_posts' ) ) {
echo get_permalink( get_option( 'page_for_posts' ) );
} else {
echo home_url();
}
?>
<?php echo home_url(); ?>
<-- Set in Settings > General > WordPress address
<?php echo site_url(); ?>
<-- Set in Settings > General > Site address
To get the Blog URL you can use the below code.
get_permalink( get_option( 'page_for_posts' ) );
If you are using WordPress 4.5+ then you can use the below code which will work for any post type.
get_post_type_archive_link( 'post' );
本文标签: permalinksLink to blog index from template
版权声明:本文标题:permalinks - Link to blog index from template 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740316381a2260384.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论