Titles and Metas for Custom Post Type are not working correctly

#17196
  • Resolved Raul
    Rank Math pro
    Content AI Creator

    Hello,

    I have several CPTs created and trying to configure “Title” for each CPT and its not working properly….

    The problem is when trying to insert CATEGORY in Title Meta. I need it to be like this:

    %title% %sep% %category% %sep% %sitename%

    I also try this becouse “eventos_cat” is the name definied for categories for this CPT but it doesn’t work either:

    %title% %sep% %everntos_cat% %sep% %sitename%

    This is the example page for this CPT:
    https://www.marketingrelacional.com/eventos/marketing-digital/eshow-barcelona/

    Can you please help me ?

    Thank you so much !!!

    • This topic was modified 4 years, 6 months ago by Raul.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Raul
    Rank Math pro
    Content AI Creator

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    The %category% variable is designed to work for posts CPT, you may have to come up with a custom replacement variable of you could create a custom PHP snippet to target this CPT as shown below:

    /**
     * Filter to change the page title.
     * 
     * @param string $title
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
    	global $post;
    	if(get_post_type()=='mec-events'){
    		$cats = get_the_category($post->ID);
            $parent = get_category($cats[1]->category_parent);
            if (is_wp_error($parent)){
            $cat = get_category($cats[0]);
            }
            else{
            $cat = $parent;
            }
    		$title = $post->post_title. " ".$cat." ".get_option('blogname');
    		return $title;
    	}
    	return $title;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Raul
    Rank Math pro
    Content AI Creator

    Thank You so much !

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Titles and Metas for Custom Post Type are not working correctly’ is closed to new replies.