wordpressmagentofishpig

Fishpig Magento - Set a template for custom post type term view


Trying to set a template specifically for a particular term using the Fishpig Wordpres/Magento plugin.

I have a custom post type called 'Business' and have categories specific to this post type.

In /app/design/frontend/themes/default/layout/wordpress.xml I have the below that renders the template for all my category terms:

<wordpress_term_view>
    <reference name="content">
        <block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml">
            <block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list.phtml" />
        </block>
    </reference>
</wordpress_term_view>

But what I need is a different template for a specific category 'executive interviews'.

You can see this here http://staging-ce.beanmediagroup.com.au/business/category/executive-interviews/.

What I've tried

I know you can set a unique page view using something like '' but this doesn't work with term ID.

I also know you can set a custom post list template for custom post types using something like /wordpress/post/list/renderer/business.phtml but this doesn't work for the terms.

Any help would be appreciated.


Solution

  • If you check this file: app/code/community/Fishpig/Wordpress/controllers/TermController.php the viewAction you can see it's adding custom layout handles:

    'wordpress_' . $term->getTaxonomyType() . '_view_' . $term->getId(),
    'wordpress_' . $term->getTaxonomyType() . '_' . $term->getId()
    

    which means, in your app/design/frontend/themes/default/layout/wordpress.xml if the ID of your desired category is 2 for example, you can add new handles specific for this category:

    <wordpress_category_view_2> <reference name="content"> <block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml"> <block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" /> </block> </reference> </wordpress_category_view_2> //OR <wordpress_category_2> <reference name="content"> <block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml"> <block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" /> </block> </reference> </wordpress_category_2> //OR <STORE_default_wordpress_category_view_2> <reference name="content"> <block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml"> <block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" /> </block> </reference> </STORE_default_wordpress_category_view_2> //OR <STORE_default_wordpress_category_2> <reference name="content"> <block type="wordpress/term_view" name="wp.term" template="wordpress/term/view.phtml"> <block type="wordpress/post_list" name="wordpress_post_list" as="post_list" template="wordpress/post/list/renderer/business.phtml" /> </block> </reference> </STORE_default_wordpress_category_2>

    Just change the 2 with the ID of your category.