Support » Plugin: Permalink Manager Lite » Breadcrumb not apply on categorie post type

  • Resolved laetitialu

    (@laetitialu)


    Hi

    hello the plugin works great for post-types permalinks and breadcrumbs.
    I checked the breadcrumb box in “Breadcrumb supports” and my breadcrumb is generated by Yoast Seo.
    But breadcrumb is not same as url for post type categories.
    Ex:
    Permalink is “/training-area/marketing-and-digital-communication/” and the breadcrumb is “home > digital marketing and communication”
    Can you help me please ?
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @laetitialu,

    Unfortunately, I am unable to provide a customized solution that would help to change the structure of the breadcrumbs since I do not provide technical help for third-party plugins such as Yoast SEO.

    I implemented breadcrumbs support as a bonus feature that is limited to the most basic scenarios.

    If you would like to change the breadcrumbs trail you will need to adjust the below code snippet to your needs:

    /**
     * Insert the new breadcrumb after "Home"
     */
    function pm_adjust_breadcrumbs($crumbs) {
    	global $post;
    
    	if(!empty($post) && $post->post_type == 'YOUR-CUSTOM-POST-TYPE') {
    		$new_crumbs = array(
    			array(
    				'Training area',
    				'https://example.com/training-area'
    			),
    		);
    
    		// Add the new breadcrumbs just after the first crumb ()"Home")
    		array_splice($crumbs, 1, 0, $new_crumbs);
    	}
    
    	return $crumbs;
    }
    add_filter('wpseo_breadcrumb_links', 'pm_adjust_breadcrumbs', 100);

    If you are not certain how to use the custom code snippets please check out the below article:
    https://permalinkmanager.pro/blog/how-to-add-php-snippet-to-wordpress-3-methods/#2-three-methods-to-use-wordpress-code-snippets

    Best regards,
    Maciej

    • This reply was modified 2 months ago by Maciej Bis.
    Thread Starter laetitialu

    (@laetitialu)

    Thanks but sorry, it doesn’t work. Did i make a mistake?
    ‘domaine-de-formation’ is taxonomy.
    Permalink : /domaine-de-formation/marketing-et-communication-digitale/
    breadcrumb : accueil/marketing-et-communication-digitale/
    My code :

    /**
     * Insert the new breadcrumb after "Home"
     */
    function pm_adjust_breadcrumbs($crumbs) {
    	global $post;
    
    	if(!empty($post) && $post->post_type == 'domaine-de-formation') {
    		$new_crumbs = array(
    			array(
    				'Domaine de formation',
    				'https://exemple.com/domaine-de-formation'
    			),
    		);
    
    		// Add the new breadcrumbs just after the first crumb ()"Home")
    		array_splice($crumbs, 1, 0, $new_crumbs);
    	}
    
    	return $crumbs;
    }
    add_filter('wpseo_breadcrumb_links', 'pm_adjust_breadcrumbs', 100);
    Plugin Author Maciej Bis

    (@mbis)

    Please use the below code instead:

    /**
     * Insert the new breadcrumb after "Home"
     */
    function pm_adjust_breadcrumbs($crumbs) {
    	if(is_tax('domaine-de-formation')) {
    		$new_crumbs = array(
    			array(
    				'text' => 'Domaine de formation',
    				'url' => 'https://example.com/test'
    			),
    		);
    
    		// Add the new breadcrumbs just after the first crumb ("Home")
    		array_splice($crumbs, 1, 0, $new_crumbs);
    	}
    
    	return $crumbs;
    }
    add_filter('wpseo_breadcrumb_links', 'pm_adjust_breadcrumbs', 1000);
    Thread Starter laetitialu

    (@laetitialu)

    Thanks you very much !! it’s work with ‘domaine_formation’ instead ‘domaine-de-formation’

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.