Genesis Blog Page Template Query Arguments Using Custom Fields

A good question from a member of the Genesis community on the StudioPress community forums :

Question : I am writing new short posts and want to have these show on a page of their own. I don’t mind them showing on the home page, but I want new people to be able to go to the Tips page and just see the tips and no other content. How is this possible?

Answer : There’s at least 2 different methods :

  1. You can use the Genesis blog page template and Genesis > Theme Settings > Blog Page Template options to show posts from any/all categories, as well as exclude categories.

  1. You can also use a custom field named query_args with different query_string values on the edit page screen of any page using the blog template.

Blog Page Setup #

  1. Create a new page.
  2. Select Blog from the Template menu in the Page Attributes meta box.
  3. Create a new custom field and use query_args as the name and cat=179 as the value for your custom field. Swap out 179 with your category id

See the following screenshot taken when testing the solution.

You can use any string of WP_Query arguments as the values for your query_args custom field key. Note : Array (s) of WP_Query arguments will not work only query strings.

Example :

See the following screenshot which shows where to add the query string in the custom field value field

The above code displays posts from category 148 ordered by date in descending order.

Show Multiple Categories Using Blog Template

Use a comma separated string of category i.d’s like this:

cat=148,191

Added to the value field for your custom field named query_args

Limit Posts Per Page Using Show Posts

You can also control, the amount of posts shown per page using showposts like this:

showposts=1

Add to query_args value field like this :

Exclude Categories #

You can use the following query_args as a guide

category__not_in=148,191

The above code will exclude posts from categories 148 and 191 from displaying using the blog template.

Here’s how the code should be used in the value field :

or use like this :

cat=-179

Related Tutorials

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.