admin管理员组文章数量:1429552
In twenty fourteen theme, we’d like to know how to change the features content tag. Currently it’s set as featured
.
Now, we would like to know how to code this for different page templates.
We notice in page.php
there is a piece of code calling the template part featured-content
.
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
From our understanding this calls the file featured-content.php
. In this file, is there a way to decide the tag. We imagine you can do it using an if statement and the $tag
or $term
variable inside an array. But we’re not completely sure.
Our idea is to create three pages on our site, each using a different tag to show different posts in the featured content section.
Can this be done and can anyone provide us with the code or logic to do it?
Thanks in advance! the LWdesign team
In twenty fourteen theme, we’d like to know how to change the features content tag. Currently it’s set as featured
.
Now, we would like to know how to code this for different page templates.
We notice in page.php
there is a piece of code calling the template part featured-content
.
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
From our understanding this calls the file featured-content.php
. In this file, is there a way to decide the tag. We imagine you can do it using an if statement and the $tag
or $term
variable inside an array. But we’re not completely sure.
Our idea is to create three pages on our site, each using a different tag to show different posts in the featured content section.
Can this be done and can anyone provide us with the code or logic to do it?
Thanks in advance! the LWdesign team
Share Improve this question edited Jun 18, 2014 at 22:22 Danger14 2192 silver badges14 bronze badges asked Feb 28, 2014 at 16:32 alexalex 1334 bronze badges2 Answers
Reset to default 5The internal implementation details of that feature are of questionable sanity.
- If you take a look at said
featured-content.php
template you would see - that it get posts from
twentyfourteen_get_featured_posts()
however - the only thing that function has is
twentyfourteen_get_featured_posts
filter - from quick look at which in peculiar fashion nothing is actually getting hooked
- because
twentyfourteen_setup()
declaresfeatured-content
feature - with configuration defining
featured_content_filter
as the one above - to which
Featured_Content
class hooks itsget_featured_posts()
method - which burrows further to
get_featured_posts_ids()
method - which calculates, caches, and returns those IDs
So there are a... few points at which you can work with... this. :)
From practical point of view you would probably want to hook into twentyfourteen_get_featured_posts
filter and conditionally return different set of posts as you need.
If you only want to change the tag on default templates, you can also do it in dashboard. :)
http://codex.wordpress/Twenty_Fourteen
本文标签: phpHow to change featured content to a different tag in Wordpress Twenty Fourteen
版权声明:本文标题:php - How to change featured content to a different tag in Wordpress Twenty Fourteen? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745543932a2662619.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论