• My site has a custom post type with 2 taxonomies (job type and location). I want to create pages manually and in these pages, I want to display a filtered list of these 2 taxonomies (example – builders in los angeles). I am creating pages manually so that when users arrive on each page, they will see an already filtered list. I dont want them to start filtering it themselves (though they can change the filteration if they wish).

    Any way to do this, especially any plugin to make it easier and faster?

Viewing 1 replies (of 1 total)
  • @dannyogolo

    Since you mentioned that the post type and custom taxonomies are already defined, you can simply make use of the “Query Loop” block on any page.

    Here’s a step by step guide for the same:

    Step 1:

    Create a page

    Step 2:

    Add “Query Loop” block, using any template you like

    Step 3:

    Edit Query Loop block settings to use the Jobs post type(assuming that’s the name of your CPT)

    Step 4:

    In the Filters section of the settings, select Taxonomies

    Step 5:

    Enter the Job Type and Location in those filters and it will display only those Jobs with the given Job Type and Location custom taxonomy terms applied to them.

    That’s its, you can then modify the template as you like.

    For the purpose of these screenshots I created CPT and custom taxonomies using following code ( not that its needed, but just sharing)

    add_action( 'init', function () {
    	register_post_type( 'job', array(
    		'label'        => __( 'Jobs', 'experiments' ),
    		'public'       => true,
    		'show_in_rest' => true,
    	) );
    	register_taxonomy( 'job_type', 'job', array(
    		'label'        => __( 'Job Type', 'experiments' ),
    		'show_in_rest' => true,
    	) );
    	register_taxonomy( 'location', 'job', array(
    		'label'        => __( 'Location', 'experiments' ),
    		'show_in_rest' => true,
    	) );
    } );
    • This reply was modified 1 year, 4 months ago by Gagan Deep Singh. Reason: Highlight Steps
Viewing 1 replies (of 1 total)
  • The topic ‘How to display combination of taxonomies of custom post type’ is closed to new replies.