Skip to main content

How to Add Blog Template Builder to Category Page

One template can draw the post list of every category. You design the list in Elementor, set one listing block to Use WP Global Query, and each category then shows its own posts in your layout, under its usual category header.

The Politics category of the PressPulse demo, its post listing drawn by a Ruby Template and outlined in orange under the category header.

What is a Category?​

The category is one of the default taxonomies in WordPress. Categories organize your content in a way that should make it easy for the user to find what they are looking for, and category pages serve as an index of all the pages and posts that belong to that particular subject.

You can refer to the URL below for further information:

https://www.wpbeginner.com/glossary/category/

To get started, follow the steps below:​

A category's own Listing Template settings win over Theme Options. So assign the template in Theme Options for every category, and leave a category's own Listing Template tab on its defaults unless that one category should look different.

  1. Create your template at Dashboard > Ruby Templates and copy its shortcode. Inside it, place one listing block for the category's posts, dragged from the Elementor panel. Foxiz - Grid 1 gives a grid like the picture above; Foxiz - Classic a one column list. Step 2 names all fifteen that can do it. To create a template, you can refer to this documentation: Ruby Templates

    The Ruby Templates list, with each template's shortcode in the Template Shortcode column

  2. In the template, click the listing block and, in its settings panel, open Content > Template Builder - Global Query > Query Mode. The section is called Template Builder - Global Query, and it is only drawn while you edit a Ruby Template. It exists on fifteen Foxiz blocks:

    • Classic: Foxiz - Classic
    • Grids: Foxiz - Grid 1, Foxiz - Grid 2 and Foxiz - Small Grid
    • Boxed grids: Foxiz - Boxed Grid 1 and Foxiz - Boxed Grid 2
    • Flex grids: Foxiz - Flex Grid 1 and Foxiz - Flex Grid 2
    • Lists: Foxiz - List 1, Foxiz - List 2 and Foxiz - Flex List
    • Boxed lists: Foxiz - Boxed List 1 and Foxiz - Boxed List 2
    • Overlays: Foxiz - Overlay and Foxiz - Flex Overlay
  3. Select Use WP Global Query for displaying the main blog listing. The block then lists the posts WordPress would show on the category page, as that page's main listing.

    Query Mode set to Use WP Global Query in the block's Template Builder - Global Query section

  4. Under Query Mode, change WP Global Query Pagination from - Disable - to Numeric. At - Disable - a category page has no page links at all. Show More (ajax) works on categories too, if you prefer a load more button.

  5. Navigate to Theme Options > Category > Global Listing Template. That section holds the template field.

  6. Input a ruby template shortcode into the or Use Ruby Template for the Post Listing input. The "or" is the Predefined Layout picker directly above it: the shortcode overrides that picker, and blank means the picker is used.

    The Global Listing Template group on the Category panel: the Predefined Layout picker and the shortcode field that overrides it

  7. Click save changes.

    If one category still shows a different listing, open its edit screen and check the Listing Template tab of its Foxiz Category Settings. Foxiz uses the first of these that is set:

    • or Use Ruby Template for Post Listing, on the Listing Template tab of that category's own Foxiz Category Settings.
    • Predefined Layout on the same tab, when it is not on - Default from Theme Options -. Picking a layout there switches the Theme Options template off for that category.
    • Theme Options > Category > Global Listing Template > or Use Ruby Template for the Post Listing, the field step 6 fills.
    • The Predefined Layout picker above that field.

    The Foxiz Category Settings box on a category's edit screen, Listing Template tab open: Predefined Layout and or Use Ruby Template for Post Listing

Notes when using WP Global Query:​

note

Don't apply the WP global query mode for more than 1 block in a template to avoid duplicated layouts.

The Query Settings are ignored in WP global query mode. The fields stay visible and are never read: in global mode the block shows the category's own posts, whatever the filters say.

The Content tab sections of a listing block: Query Settings, Ajax Pagination and Unique Post stay on screen in global query mode

Unique Post, in its own Unique Post section, is the one query setting that survives global mode: it re-runs the query without the posts an earlier block on the page already used. Its default is Disable.

Use WP Global Query Pagination instead of Ajax Pagination: the Ajax Pagination settings are ignored in WP global query mode. WP Global Query Pagination sits in the same Template Builder - Global Query section and its default is - Disable -, and at that value a category page gets no pagination at all. Pick Numeric, Simple, Show More (ajax) or Infinite Scroll (ajax) instead. Both AJAX values do work on a category listing.

To change the number of posts per page, navigate to Theme Options > Category > Posts per Page. That number applies to the Ruby Template as well as the predefined layouts. A single category's own Posts per Page in Foxiz Category Settings beats it. With both empty, the page uses the WordPress Settings > Reading value.

The Posts per Page field on the Category panel

Tip: set Number of Posts in the block's Query Settings to the number the page shows on the front end, so the editor preview looks like it. That number is for the editor only and the plugin's own tip says it will not apply on the front end.

The Number of Posts field at the foot of the block's Query Settings section

The "WP global query mode" layout cannot execute in this live editor. Check the result on the front end, once the template is assigned.