Community Forums › Forums › Archived Forums › Design Tips and Tricks › Post Format Archive
Tagged: archive, Post Formats
- This topic has 6 replies, 2 voices, and was last updated 7 years, 11 months ago by pixeldapper.
-
AuthorPosts
-
May 6, 2016 at 4:21 am #185079pixeldapperMember
Hi!
http://prototypes.superhappypath.co.uk/dads
I would like to create an archive page for the video post format and add it to my main navigation. Is this possible?
I am using the Digital Pro ThemeMay 6, 2016 at 5:18 am #185084Victor FontModeratorPost formats are WordPress taxonomies. You can filter a query for a specific page by taxonomy. I cobbled this code together for you, but it may need further tweaking. I don't have a way of testing it in my local environment. I don't use post formats.
function filter_video_format_posts($query) { // change 999 to the page id for your archive page if ( !is_page ('999') ) return $query; $taxquery = array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-video' ), ) ); $query->set( 'tax_query', $taxquery ); } add_action( 'pre_get_posts', 'filter_video_format_posts' );
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 6, 2016 at 7:53 am #185092Victor FontModeratorTry this. I replied to this post earlier, but for some reason the answer didn't show up.
Post formats are WordPress taxonomies. You can filter a query for a specific page by taxonomy. I cobbled this code together for you, but it may need further tweaking. I don't have a way of testing it in my local environment. I don't use post formats.
function filter_video_format_posts($query) { // change 999 to the page id for your archive page if ( !is_page ('999') ) return $query; $taxquery = array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-video' ), ) ); $query->set( 'tax_query', $taxquery ); } add_action( 'pre_get_posts', 'filter_video_format_posts' );
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 6, 2016 at 7:53 am #185093Victor FontModeratorI tried to answer your question twice and neither time would the answer display.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 6, 2016 at 8:03 am #185097Victor FontModeratorfunction filter_video_format_posts($query) { // change 999 to the page id for your archive page if ( !is_page ('999') ) return $query; $taxquery = array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-video' ), ) ); $query->set( 'tax_query', $taxquery ); } add_action( 'pre_get_posts', 'filter_video_format_posts' );
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 6, 2016 at 8:08 am #185098Victor FontModeratorI just tried posting the code by itself and it won't post., so I created a Gist that has the code: https://gist.github.com/vfontjr/9836af69d6bc2e01926c9b7503d0309f
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?May 9, 2016 at 4:03 am #185256pixeldapperMemberThanks Victor,
It seems that the answer was appearing. Thank you so much for your persistence. It works great!
Laurence
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.