How to use SEO Titles and Meta in Custom Post Types

#55664
  • Resolved Anonymous
    Rank Math free

    Hi
    I have a site with several custom pages based on one template (created with toolset) that display custom fields.

    I want to set a dynamic Title and a dynamic Description on all pages and I see that we have an excellent way to do this in RankMath – and to my surprise, my custom post type is actually listed in the “Post Types”, under SEO Titles and Meta section of “Titles and Meta” menu item. On this page, we have a superb way of setting SEO for all pages using dynamic parameters.

    If I set the Title, all pages do get that title and that saves a ton of time.
    BUT if I set the description, none of the pages get that description, and instead, all pages seem to pick up data from the “excerpt” field.

    Have I missed something? Or is this a bug? Is there a fix or a workaround?

    Thanks everyone for help.
    Mike

    • This topic was modified 5 years ago by . Reason: To make the error clearer to understand
Viewing 7 replies - 1 through 7 (of 7 total)
  • Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank Math today.

    Unfortunately, I’m not able to replicate this issue on my end. How are you adding the description?

    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.

    Anonymous
    Rank Math free

    I am also experiencing this issue with AIT Themes DirectoryPro.

    Anonymous
    Rank Math free

    Hello,

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

    Thank you.

    Michael Davis
    Rank Math pro

    Hello,

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

    I ma unable to edit your function.php. Please add the following function to use the global settings if the on page meta is not set.

    /**
     * Use the Description from Global Setting, if the description is missing in the Post metabox
     */
    add_action( 'rank_math/frontend/description', function( $description ) {
     global $post;
     $desc = RankMath\Post::get_meta( 'description', $post->ID );
    
     if ( ! $desc ) {
     $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
     if ( $desc ) {
     return RankMath\Helper::replace_vars( $desc, $post );
     }
     }
    
     return $description;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Anonymous
    Rank Math free

    Hi Michael

    Your suggestion that I add the code to functions.php means when I update the theme, the supplied php code will be overwritten and the descriptions will revert to the content of some other field (as is happening now)..

    I have to weigh up whats better for my case – to apply the meta-description to each page, or to update the functions.php and then add this code each time I update the theme….

    As this is supposed to be a built in feature of the rankmath, when would an updated version be released with this code ?

    Thanks Michael.

    Anonymous
    Rank Math free

    Hi Michael

    Just to update you and anyone else with this issue.
    The code you attached does work.

    To add it to the theme without editing the functions.php, I have used a plugin called “code snippets” version 2.14.0 by Code Snippets Pro. This allowed me to add the snippet in a plugin, to enhance the functions defined in functions.php

    That way, if and when we get a theme update, the theme can be updated without having to re-upload the rank-math patch (as the code is safely in the plugin.)

    The only thing to watch for is when you add this functionality in RankMath, we will need to remove the extra code in the plugin, otherwise it could be a problem.

    So the preferred solution is still to get the updated rank-math plugin with this code.

    Id appreciate it if you can give me any feedback on when you expect to release an update with above.

    Thanks.

    Todd
    Rank Math free

    Hello,

    We are glad it is sorted now.

    We will see about improving that in an upcoming update.

    Thank you.

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

The ticket ‘How to use SEO Titles and Meta in Custom Post Types’ is closed to new replies.