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
The internal implementation details of that feature are of questionable sanity.
featured-content.php
template you would seetwentyfourteen_get_featured_posts()
howevertwentyfourteen_get_featured_posts
filtertwentyfourteen_setup()
declaresfeatured-content
featurefeatured_content_filter
as the one aboveFeatured_Content
class hooks itsget_featured_posts()
methodget_featured_posts_ids()
methodSo 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.org/Twenty_Fourteen