WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Breadcrumb NavXT] Custom post type support

[Resolved] [Plugin: Breadcrumb NavXT] Custom post type support

  • Hello,

    I was looking forward custom postype support but 3.6 doesn’t follow the rewrite slug I define.

    Custom post type are not always blog posts, I personnaly use custom post types as pages. I often redifine the rewrite slug and remove the front blog prefix. Example, for a school posttype I set

    Rewrite Slug: informations/schools (information and schoold are exiting pages. Doing this way a my_school school url would look like this:

    informations/schools/my_school

    But the breadcrumb shows:

    Home > Blog > my_school

    Whereas it should display:

    Home > Informations > Schools > my_school

    So here are my questions: is that behavior possible to achieve in in 3.6?

    If not, is it planned?

    Best regards

Viewing 15 replies - 1 through 15 (of 55 total)
  • Plugin Author John Havlik

    @mtekk

    Dreadlox,

    The current implementation was done several months ago and I asked for input on it. From the little feedback I received, it did what the users were looking for. See this post on the explanation of what is supported in 3.6.0’s custom post type support: http://mtekk.us/archives/wordpress/plugins-wordpress/breadcrumb-navxt-custom-post-type-support/

    You are running into what seems to be two (or three) issues.

    The first is that I assumed (carried over from the old post type) that flat post types would be a child of “blog”, while all hierarchical posts (carried over from old page type) are children of only the root page. I see where this is not always the case and can add in the option (it will hit the SVN trunk probably late this week, I well respond in this post when I have committed it to the SVN trunk).

    The second seems to be you are performing a “hierarchy flip” (somewhat covered in the linked post above). Traditionally, the solution here is to have Schools and Informations be terms of a hierarchical taxonomy (this is a fully supported method in 3.6.0, minus the “blog” breadcrumb that was explained above).

    If Informations and Schools are pages (the post type of page that has been in WordPress since 1.5 or so), and Schools is a child page of Informations, then my_school would need to be a child of Schools. This is not exactly supported at the moment. The underlying code is there for one flat to hierarchical post type “hierarchy flip” (as long as the destination is of the type page), but the front end (settings page) does not support it for all types. However, if you can set the ‘post_POSTTYPEHERE_taxonomy_type’ array member in the opt array (part of the bcn_breadcrumb_trail class) to “post”. Note that you need to replace POSTTYPEHERE with the name of the post type you are using for my_school.

    Ok that was probably long and confusing. The good news is I’m going to change the settings page to accommodate custom taxonomies and post types in a easier to understand way, and at the same time I will add in the extra code to make what you are tying to do work (provided that you make sure my_school has Schools set as its parent).

    -John Havlik

    Are there any news regarding this situation?

    I’ve a custom post type called demaweb_products. I’ve a page called products using a custom template from my theme which display a archive of my demaweb_products. It’s on the page: /products/.

    The url for my custom posts are eg.: /products/cms/

    When I eg. visit /products/cms/ the breadcrumb only displays: Home > CMS.

    I would like it to be:
    Home > Products > CMS.

    Is that possible?

    Plugin Author John Havlik

    @mtekk

    DreadLox and DennisMadsen,

    The current SVN trunk should allow you to use pages as a hierarchy type for any flat post type. The “core” of Breadcrumb NavXT allows for any hierarchical post type to be the hierarchy for any post type, I just need to finish extending the “front end”/settings page.

    As for removing the blog part in DreadLox’s post, I am working on the modifications to the “core” tonight for that.

    DennisMadsen

    @dennismadsen

    Thanks.
    From where can I download the SVN trunk?

    Plugin Author John Havlik

    @mtekk

    Grab the “Development Version” from this page: http://wordpress.org/extend/plugins/breadcrumb-navxt/download/

    DennisMadsen

    @dennismadsen

    When activating the taxonomy display for my custom post type, I got this error when displaying the creadcrumb in frontend:
    Fatal error: Cannot access protected property bcn_breadcrumb::$title in ...\wp-content\plugins\breadcrumb-navxt\breadcrumb_navxt_class.php on line 455

    Plugin Author John Havlik

    @mtekk

    My bad, I forgot to update that section of code. The SVN Trunk should now have that fixed.

    DennisMadsen

    @dennismadsen

    How can I change the “Untagged” to a link to my product page?

    DennisMadsen

    @dennismadsen

    I inserted ‘post_demaweb_product_taxonomy_type’ => ‘post’ into the array and made the custom post type hierarchical. Now it displays the parent post. Thats a nice feature – but not what I wanted.

    Instead I would like the opportunity to define a custom taxonomy to be displayed before the product in the breadcrumb trail – instead of the parent product. I was told on this forum, that the best way to create an archive for my products, was to create a custom page template and create a page using that template. Because of that WP does not know, which page that is parent for my products. Therefore it would be great, if I could create a custom product taxonomy in the backend under the product tab. Here I would like to define the URL to the product archive (In my case /products/) – the title of the page can be queried from the page title.

    Maybe I’m wrong. But how could I else create a custom archive for my product on /products/ in a way, that will work with your plugin?

    Thanks for your time!

    Plugin Author John Havlik

    @mtekk

    The untagged thing should be dynamic in the SVN Trunk now (forgot to update that earlier).

    I inserted ‘post_demaweb_product_taxonomy_type’ => ‘post’ into the array and made the custom post type hierarchical. Now it displays the parent post. Thats a nice feature – but not what I wanted.

    By setting the taxonomy type for the demaweb_product custom post type to post (not an available option in the settings page), you are telling Breadcrumb NavXT to use posts as the taxonomy, and inherit the post’s taxonomy. However, if demaweb_product is a hierarchal custom post type, it should ignore the taxonomy_type setting (automatically crawls the hierarchy until it gets to the root page of the site).

    Instead I would like the opportunity to define a custom taxonomy to be displayed before the product in the breadcrumb trail – instead of the parent product.

    You can do this, no problem. Just set the custom post type to “normal/flat” (non-hierarchical), and define which taxonomies are valid for that type. Then, in the settings page of Breadcrumb NavXT, under the tab for the post type you are using, you should be able to select from the valid taxonomies for that post type.

    I was told on this forum, that the best way to create an archive for my products, was to create a custom page template and create a page using that template. Because of that WP does not know, which page that is parent for my products.

    This has caused many issues before. I don’t know who keep recommending this, but they must not be aware of some of these issues with it. The only advantage to that method is you can have some custom text on the products page that can be edited via the standard edit panels. The way I’d suggest doing this is to have a template file for your custom taxonomy, and have it display the taxonomy tag description for your additional information.

    Therefore it would be great, if I could create a custom product taxonomy in the backend under the product tab. Here I would like to define the URL to the product archive (In my case /products/) – the title of the page can be queried from the page title

    Where are you talking about for this?

    DennisMadsen

    @dennismadsen

    This has caused many issues before. I don’t know who keep recommending this, but they must not be aware of some of these issues with it. The only advantage to that method is you can have some custom text on the products page that can be edited via the standard edit panels. The way I’d suggest doing this is to have a template file for your custom taxonomy, and have it display the taxonomy tag description for your additional information.

    I’m going 2 steps back and starting over again. I would like to use your solution, but I did not get point completely.

    Here is the code for my custom post type:

    register_post_type( 'demaweb_product',
    		array(
    			'labels' => array(
    							'name' => __( 'Products' ),
    							'singular_name' => __( 'Product' ),
    						),
    			'public' => true,
    			'rewrite' => array('slug' => 'products'),
    			'supports' => array('title','editor','excerpt','page-attributes','revisions'),
    		)
    	);

    I found this example of how to create a custom taxonomy:
    http://codex.wordpress.org/Function_Reference/register_taxonomy#Example

    But how should I define the taxonomy? Should I eg. create this hierachical taxonomy called “product”:

    register_taxonomy('product',array('demaweb_product'), array(
        'hierarchical' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'products' ),
      ));

    I then guess, that the URL /products/ would act like the normal /category/ URL – but now showing a archive for the taxonomy? But how can I then create a custom file in my theme defining the layout of my /products/ page? Right now I got the 404-page.

    Plugin Author John Havlik

    @mtekk

    For a taxonomy to show up for a custom post type (from what I have seen), you need to use something like:

    register_post_type( 'demaweb_product',
    array(
    	'labels' => array(
    		'name' => __( 'Products' ),
    		'singular_name' => __( 'Product' ),
    	),
    	'public' => true,
    	'rewrite' => array('slug' => 'products'),
    	'supports' => array('title','editor','excerpt','page-attributes','revisions'),
    	'taxonomies' => array('product')
    )
    );

    I then guess, that the URL /products/ would act like the normal /category/ URL – but now showing a archive for the taxonomy

    Yes, /products/ should then show your products archive. To add the extra template for your theme, you’ll want to create a taxonomy-product.php (see http://codex.wordpress.org/Template_Hierarchy for more information).

    DennisMadsen

    @dennismadsen

    I’ve tried with this custom post type and custom taxonomy:

    register_post_type( 'demaweb_product',
    		array(
    			'labels' => array(
    				'name' => __( 'Products' ),
    				'singular_name' => __( 'Product' ),
    			),
    			'public' => true,
    			'rewrite' => array('slug' => 'products'),
    			'supports' => array('title','editor','excerpt','page-attributes','revisions'),
    			'taxonomies' => array('product')
    		)
    	);
    
    register_taxonomy('product',array('demaweb_product'), array(
        'hierarchical' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'products' ),
     ));

    When visiting the /products/ URL I got the 404.php file. I’ve created a empty files for both taxonomy.php and archive.php, but none of them are called. I’ve created three posts in my custom post type but I have not created any items in my product-taxconomy – even if I create a dummy item here, I still got the 404.php file.

    Do you know what the problem is?

    Plugin Author John Havlik

    @mtekk

    Make sure you register your taxonomy first. Regardless of this, I’ve inadvertently lead you astray. I forgot that WordPress still does not do “global” (for a lack of a better word) archives for taxonomies (e.g. an archive containing all categorized or all tagged, or all custom taxonomied post types). Before the advent of custom post types (and custom taxonomies) this did not make sense to have, now, IMHO, it does. I need to ponder on this for a little bit (I have a project that is going to run into this issue shortly).

    DennisMadsen

    @dennismadsen

    Ok, hope you will come back, when you found the way to do it.. In the mean time, I’ll keep using the method with the custom page template.

    Thank you!

Viewing 15 replies - 1 through 15 (of 55 total)
  • The topic ‘[Resolved] [Plugin: Breadcrumb NavXT] Custom post type support’ is closed to new replies.