Support » Plugin: All in One SEO Pack » Replacing specific characters in the document.title

  • Resolved herbertwest1

    (@herbertwest1)


    Hello,

    I want to replace some specific characters in my document.title because they take too much space in the SERPs.
    eg : « » that I would like to replace by ” or ” (if it doesnt break the title), JUST in the title, meta description and & social (facebook og & twitter cards).

    In my header.php I do have the twitter cards & og, but I cannot find the title nor the meta description.
    Not in this file nor the functions.php where I do have

    /////////////////////////////////////
    // Title Meta Data
    /////////////////////////////////////
    
    add_theme_support( 'title-tag' );
    
    function mvp_filter_home_title(){
    if ( ( is_home() && ! is_front_page() ) || ( ! is_home() && is_front_page() ) ) {
        $mvpHomeTitle = get_bloginfo( 'name', 'display' );
        $mvpHomeDesc = get_bloginfo( 'description', 'display' );
        return $mvpHomeTitle . " - " . $mvpHomeDesc;
    }
    }
    add_filter( 'pre_get_document_title', 'mvp_filter_home_title');
    
    /////////////////////////////////////

    Any idea where I should look at, or how to replace those characters in the title & description?

    Thanks !

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    You should remove the twitter cards and OG from your header.php and let AIOSEOP add them. Leaving them in will result in two sets.
    To change the title you can use our API filter hook aioseop_title. https://semperplugins.com/documentation/aioseop_title/

    Thanks @hallsofmontezuma , i’ll look into your link for the title.

    As for the twitter cards & og, I don’t remember the specifics, I need to look into it again, but I sort of remember that I did put them in my header.php because otherwise they wouldnt work properly.
    Like they were appearing twice in the articles, or on the articles but not the hp, or something like that. Something was off, hence why I chose it…

    Given the link : https://semperplugins.com/documentation/aioseop_title/

    I am guessing that if I edit : /aioseop_class.php
    My modifications will disappear whenever I update the plugin?

    Plugin Author Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    I did put them in my header.php because otherwise they wouldnt work properly.
    Like they were appearing twice in the articles

    As I said, they will be there twice if you hardcode them in your theme. This is AIOSEOP’s responsibility.

    I am guessing that if I edit : /aioseop_class.php

    I never said to modify the plugin. If you read that page, you’ll see that it links to documentation on where to apply custom code snippets.

    Hello @hallsofmontezuma ,

    Sorry for the late reply.
    After further testing, it seems that if I take off the hardcoding of the metas, I do not see any extra issue. Nor on the homepage, nor the articles. I am guessing that the issue I noticed in the past has been fixed.

    Now I need to look at that char replacement 🙂

    Hey, I don’t know if you would be able to help me further with the char replacement, but just in case.

    I want to replace the « » (as in : « lorem ») in my titles.
    So following the documentation, and using custom code snippets :
    add_filter( ‘aioseop_title’, ‘change_wordpress_seo_title’ );
    function change_wordpress_seo_title( $title ){
    $title = str_replace(‘« ‘, ‘”‘, $title);
    $title = str_replace(‘»’, ‘”‘, $title);
    return $title;
    }

    This replaces correctly the « »
    Eg : « lorem ipsum »
    Will be turned into : ” lorem ipsum ”

    I want to also get rid of the space before and after.
    If I try :
    $title = str_replace(‘« ‘, ‘”‘, $title);

    It simply do not replace anything.
    The weird part is that in phpmyadmin, the title of the article seems to be : “lorem ipsum”
    But in the sourcecode it’s : « lorem ipsum »

    1) Is wordpress customising the visual aspects of quotes?
    2) Any idea of how to replace both the quotes but also the space before/after those quotes so that it takes less space?

    Thanks !

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