Creating WordPress Custom Category Templates & WP_Query



Have you ever wanted to create a custom template for an individual category? Ever wondered how you can change what gets displayed on your homepage? If you’ve wanted to customize your blog by category, author, or other meta data, this video shows you how to edit the loop, with WordPress’s very powerful WP_Query. You can get just about any kind of posts you want or exclude certain kinds of posts as well.

As mentioned in the video, here is the code you need to manually create new pages in your WordPress theme WITHOUT the need for FTP at all. This is a great little trick I learned. Here’s the code you’ll need to put in the header.php file:

in php code:
touch(‘wp-content/themes/YOURTHEMENAME/category-SLUG.php’);

Don’t forget to replace YOURTHEMENAME and SLUG with the values you have, as explained in the video.

Here is the WordPress Codex page that talks about ways to customize the loop with WP_Query. All the useful variable names are here so you can quickly find the type of posts you want in about 5 minutes. It is very straightforward and simple to do.

WP_Query on the Codex:
https://codex.wordpress.org/Class_Reference/WP_Query

Website/Blog: http://overthink.io
HD Video Courses: http://overthink.io/udemy
Twitter: http://twitter.com/overthinkio
Facebook: https://www.facebook.com/Overthink-648528591917718/

source

Reply

Do NOT follow this link or you will be banned from the site!