Im developing a "catalogue" plugin using a custom post type and a custom taxonomy. What I want now is to display the custom taxonomy as a single page. That means I if the taxonomy term "Popular Items" is requested I want to query all posts for this category, render and buffer my own template (phtml) including all posts belonging to that taxonomy term as a table. This buffered table should be rendered using the default single template file from the theme. So without any pagination or multiple posts at one page.
I tried to customize the WP_Query and generate a new one inside the pre_get_posts action but got no results emulating a single post query with my own content.
add_action("pre_get_posts", array( $this, 'check_for_iccat' ) );
...
public function check_for_iccat( $query ) {
if( is_tax( 'iccat' ) ) {
$termId = get_queried_object()->term_id;
echo "<pre>"; print_r ($query); echo "</pre>";
exit(); // debug view
}
}
Another idea is to create a second post-type injecting the rendered category buffer and displaying as page.
Any suggestions how I can do this?
Update: Another way to achieve this is to save the rendered category output into the database and provide a shorttag like [category=popular]. This tag can be used inside a normal page or post. Before the post / page is rendered I can replace it with the pre rendered and cached content. Is that the only solution? I'm looking for a more automatic solution.
Thanks in Advance!
Aucun commentaire:
Enregistrer un commentaire