Use custom field as title element but modify its value

#560406
  • Resolved Anonymous
    Rank Math free

    Hello,

    I have a custom field called “listing_type”, which I want to use in a post types seo title element. Unfortunally, the listing type is sanitized in the database. So I had to modify the code getting the custom field (see below). Is there any hook / action / filter I can use so that I do NOT have to edit rankmath core files anymore?

    Thanks in advance!

    public function get_customfield( $name ) {
    global $post;

    $on_screen = is_singular() || is_admin();
    $has_post = is_object( $post ) && isset( $post->ID );
    if ( Str::is_non_empty( $name ) && $on_screen && $has_post ) {

    $name = get_post_meta( $post->ID, $name, true );

    if ( '' !== $name ) {
    if($name == "grundstuecke")
    {
    $name = "grundstücke";
    }
    if($name == "buero")
    {
    $name = "büro";
    }

    return ucfirst($name);
    }
    }

    return null;
    }

Viewing 1 replies (of 1 total)
  • Hello,

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

    Would you please confirm if you’re using ACF for custom field generation? If yes, you can use %customfield(field-name)% shortcode to display the content of the Custom field in SEO title.

    Please let me know if you’re using any other method to generate the custom field and we’ll look into it.

    Looking forward to helping you.

    Thank you

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Use custom field as title element but modify its value’ is closed to new replies.