• Skip to content

Victor Font Consulting Group, LLC

Digital Business Strategists

Call Us Toll Free:

1-844-VIC-FONT (842-3668)

  • Home
  • Portfolio
  • Care Plans
  • Shop
  • FAQs
  • Support
  • Our Team
    • Contact
    • Make Appointment
    • Speakers
  • Resources
    • Free WordPress Video Training
    • Graphic Design
    • Articles
    • Cybersecurity
    • Tutorials
    • Code Snippets
    • Free Plugins
    • EU Referral Network
You are here: Home / Code Snippet / Filter WordPress Query by Post Format

Filter WordPress Query by Post Format

By Victor M. Font Jr.
May 26, 2016Leave a Comment

I would like to create an archive page for the video post format and add it to my main navigation. Is this possible?—Pixeldapper, Studio Press Forum

Add the following to your theme's functions.php:

Filter WordPress Query for Post Formats
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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' );

  • 2shares
  • Facebook0
  • Twitter0
  • Google+0
  • Pinterest0
  • LinkedIn2
  • Print
  • SMS0

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Reader Interactions

VictorFont.com runs on the Genesis Framework

Genesis FrameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Check out the incredible features and the selection of designs. It's that simple—start using Genesis now!

Click here to download The Genesis Guide for Absolute Beginners (PDF - 1.4 MB)

Leave a Reply Cancel reply

Your email address and website will not be published. Required fields are marked *
Posting a comment means that you agree with and accept our Comment & Product Review Policy

Toll free: 844-VIC-FONT (844.842.3668)

Send us an E-mail Fax: 919.205.4446

Affiliate Marketing Disclosure | Comment & Product Review Policy

Privacy Policy | Cookie Policy | Site Map

Copyright © 2003–2019 Victor M. Font Jr.

Return to top of page
Cover image: 5 Things You Can Fix On Your Website In The Next Week To Increase Engagement

Attract New Customers Automatically for Free!

  • Learn how to use the Internet to attract REAL clients
  • Avoid the 3 big mistakes EVERYBODY makes
  • Put this system on AUTOPILOT with the tools the Pros use!

GET YOUR COPY!

This little ebook has helped hundreds of business professionals get real results.
Now it's your turn!

ebook lead capture
Privacy Policy
{"cookieName":"wBounce","isAggressive":false,"isSitewide":true,"hesitation":"","openAnimation":false,"exitAnimation":false,"timer":"","sensitivity":"","cookieExpire":"7","cookieDomain":"","autoFire":"","isAnalyticsEnabled":false}
We only use analytical cookies on our website that allow us to recognize and count the number of visitors and to see how visitors move around the site when they are using it, but they do not identify you individually. They help us to improve the way our website works, for example by ensuring that users are finding what they are looking for easily. Read more about the cookies we use by clicking the Cookie Policy button. By clicking OK you agree to cookies being used in accordance with our Cookie Policy. If you don’t agree you can disable cookies—see the Cookie Policy for more details.
Ok No Cookie Policy