• Resolved jamesthemonkeh

    (@jamesthemonkeh)


    Hello

    I currently have a WordPress website using Squirrly for SEO. However, on archive pages, it is using descriptions/titles from the first content page that belongs to the archive page.

    So for example, on my accommodation archive page, that lists all the hotels, the title is “Hotel 1”, and the description is “Hotel 1 is a beautiful…”. They should instead be referencing the title “List of Accommodation”, and description “These are all the hotels…”.

    I am trying to write an over-ride for this – I did find one for Yoast SEO listed here – https://wordpress.stackexchange.com/questions/61472/using-php-to-overwrite-or-replace-title-tag-while-using-yoast/61523#61523?newreg=a3496de25de941a7bb16089b1912653b but this is not working, assumedly because wpseo_title is a filter specific to Yoast.

    My current code is:

    <?php get_header();
    if ( is_archive() ) {
    add_filter(‘wpseo_metadesc’, ‘filter_product_wpseo_metadesc’);
    function filter_product_wpseo_metadesc($wpseo_metadesc) {
    if( is_singular( ‘product’) ) {
    $wpseo_metadesc = “This is a big test of stuff”;
    }
    return $wpseo_metadesc;
    }
    } ?>

    Does anyone know a filter, or similar, that would over-ride the SEO for my archive pages, either specific to Squirrly SEO, or one which would work in general?

    Many thanks
    James

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Paul Sorel Nagy

    (@nagysorel)

    Hey,

    This could be a solution:

    Make sure you add the hook before “wp_head” (get_header();)

    if ( is_archive() ) {
    add_filter(‘sq_title’, ‘filter_product_wpseo_metadesc’);

    function filter_product_wpseo_metadesc($wpseo_metadesc) {
    if( is_singular( ‘product’) ) {
    $wpseo_metadesc = “This is a big test of stuff”;
    }
    return $wpseo_metadesc;
    }
    }

    get_header();

    You can change the title and description in Squirrly by calling the filters: sq_title and sq_description

    Regards,
    Sorel

    Thread Starter jamesthemonkeh

    (@jamesthemonkeh)

    Hi Sorel

    Thank you for your response. I have amended it to read:

    <?php
    if (is_archive()){

    add_filter(‘sq_title’, ‘filter_product_wpseo_metadesc’);

    function filter_product_wpseo_metadesc($wpseo_metadesc){

    if (is_singular(‘product’)){
    $wpseo_metadesc = “This is a big test of stuff”;
    }

    return $wpseo_metadesc;
    }
    } get_header();
    ?>

    However it is still not over-riding the Squirrly SEO.

    Do you have any further ideas?

    Kind regards
    James

    Thread Starter jamesthemonkeh

    (@jamesthemonkeh)

    I should also add that this was placed in the specific archive page.

    If I place it in my functions page instead, I get the following error:

    Fatal error: Call to a member function addToScript() on a non-object in /nas/content/staging/gfacstage/wp-content/plugins/addthis/addthis_social_widget.php on line 1371

    Plugin Contributor Calin Vingan

    (@calinvingan)

    Hey,

    That error is not from Squirrly (/wp-content/plugins/addthis)

    Please look into that error.

    Best regards,
    Calin

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to over-ride meta data in WordPress’ is closed to new replies.