Skip Navigation

[Resolved] Custom Post grid reuseable

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 2.44 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 11 replies, has 2 voices.

Last updated by Luo Yang 2 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2261537

I archived this:
https://toolset.com/forums/topic/build-a-post-grid-with-custom-link/

There i build a Post Grid and all works i mentioned.

But how can i duplicate this? Or with other words i need this a few times on the page just with another Tax output.
Eg. on the one site i only need the posts with category b and on another site i only need to display posts with category c.

How can i fix this that i can use the same grid and just change the tax/category output/filter?

#2262405

Hello,

I suggest you try these:
1) Create a content template, setup the conditional blocks in it, and display it as what you want
2) In other views/page/post, display a content template block, and choose above content template
https://toolset.com/block-item/content-template/

#2262723

I did but how can i set up which categories to display?

As i wrote ... i want to use the same template few times.

i tryed this:
[wpv-view name="hersteller-grid" hersteller-kategorie="premium"]

but it dont works.
the custom post type is created like this:

// Our custom post type function
function create_posttype() {
 
    register_post_type( 'hersteller',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'Alle Hersteller' ),
                'singular_name' => __( 'Hersteller' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'hersteller'),
            'show_in_rest' => true,
			'supports' => array('title','editor','excerpt', 'author','thumbnail','custom-fields','page-attributes'),
        )
    );
	
	register_taxonomy('hersteller-kategorien', 'hersteller',
        array(
			'show_in_rest' => true,
            'hierarchical' => true,
            'label' => 'Kategorien',
            'query_var' => true,
            'rewrite' => array(
                'slug' => 'hersteller-kategorie',
                'with_front' => false  
            )
        )
    );
}
#2263253

What do you mean it does not work?

Please elaborate the questions with more details, provide detail steps to reproduce the same problem, you can also provide a test site with the same problem, also point out the problem page/post URLs, take a screenshot for what you are going to achieve, I need to test and debug it in a live website, thanks

#2263329

I made the content template as described.

Now when i place it in content i want to choose/filter which category posts should display on page.

#2263389

Since you are using custom codes to setup the post types + taxonomies, I suggest you try to follow our document to convert those post types + taxonomies to Types control:
https://toolset.com/course-lesson/convert-existing-custom-types-and-fields-to-types-control/

And test again.

#2263437

Ok so this works now:
[wpv-view name="hersteller-grid" wpvherstellerkategorien="city-trekking"]

Can i only use Shortcode? Its not possible to use Content Template block instead?

#2263445

The shortcodes you mentioned above is a view's shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view

You can put it into a Toolset content template, then display the content template with the content template block

#2263451
Bildschirmfoto 2022-01-11 um 09.45.03.png

yes i did it with content template block but then i cant choose the category?

it looks like this:
hidden link

and the settings linke screenshot to display the category.

Or what are the right filter settings?

#2264211

The attribute "wpvherstellerkategorien" is setup in the view's shortcode [wpv-view], so it is expected result: you can not choose "category" in content template.

Content templates are different from post views.

In your case, you just need to add a shortcode block, display the view's shortcode with different "wpvherstellerkategorien" attribute value, for example:

[wpv-view name="hersteller-grid" wpvherstellerkategorien="city-trekking"]
[wpv-view name="hersteller-grid" wpvherstellerkategorien="city-abc"]
[wpv-view name="hersteller-grid" wpvherstellerkategorien="city-def"]

#2264515

ok so its only possible with shortcode. ...

that would be great features ... for now where block theming is coming more and more

#2265111

As I mentioned above content templates are different from post views, you can not use views attribute in content template