• Resolved oneray

    (@oneray)


    Hi,
    1) please check the products links in this page, these are dynamic pages within this page: /shop … Rank Math is picking this base url as canonical which is totally useless >> www . online-ebook-download.com/blog/shop

    I guess there is no need for canonical URL here ?!
    or if there is, then how to add these dynamic product page URLs as canonical for each category page ?

    can you please add an option in the settings / a checkbox to enable or disable canonical URLs in the next updates ? that will be really helpful.

    2) Is there a way to add the first H2 (which is the “category” name) to the meta title, for dynamically created content in each product page?!
    for example >>
    https://www.online-ebook-download.com/blog/shop?cs_category=251

    maybe “first H2” variable, or first line/text variable if that’s possible ?!

    Thanks.

    • This topic was modified 6 years ago by oneray.

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • MyThemeShop

    (@mythemeshop)

    Hello @oneray

    Thank you for contacting the support.

    1. You can use the following filter and add the query string manually to the canonical URLs

    add_filter( 'rank_math/frontend/canonical', function( $url ) {
        return $url . '?' . $_SERVER['QUERY_STRING'];
    });

    2. You can use the rank_math/frontend/title filter to add any information you want to the titles.

    Hope that helps. If you have any further question(s), please let us know.

    Thread Starter oneray

    (@oneray)

    Hello,
    well, I’m new to all this stuff, how and where exactly should I add these ?!

    please do consider adding a simple checkbox to enable or disable canonical URLs..

    Thanks.

    Thread Starter oneray

    (@oneray)

    An option for enabling or disabling canonical URLs on individual pages or posts will be helpful.

    I just want to disable canonical URL on this page only.

    MyThemeShop

    (@mythemeshop)

    Hello @oneray

    Please add the code in your theme’s functions.php file.

    Since we are keeping the plugin simple and easy to use, especially to the new users, we are not sure if an option will be added for it in the plugin.

    However, you can easily change the output and disable the canonical URLs by using a filter.

    Looking forward to helping you. Thank you.

    Thread Starter oneray

    (@oneray)

    it worked.. however, another problem appeared now..!!
    this filter is adding a question mark “?” after all posts and pages canonical URLs, even in the homepage, check these for example:

    https://www.online-ebook-download.com/blog
    https://www.online-ebook-download.com/blog/free-ebooks
    https://www.online-ebook-download.com/blog/salehoo-wholesale-suppliers-for-ebay

    Thread Starter oneray

    (@oneray)

    if this helps, here are the 2 parameters that are stripped out of the canonical URL (before adding your filter) >>
    cs_category and cs_keywords

    for “cs_category” parameter, each one of these “category” full links should be included in each page’s canonical >>
    /shop?cs_category=1
    /shop?cs_category=2
    /shop?cs_category=3
    etc..

    and for “cs_keywords” parameter, each one of these “search keyword” links should be included in each page’s canonical >>
    /shop?cs_keywords=health
    /shop?cs_keywords=design
    or whatever search term..

    Thanks a lot for the help..

    MyThemeShop

    (@mythemeshop)

    Hello @oneray

    Can you please try with the following code?
    Please tell him to use below code to change canonical URL:

    add_filter( 'rank_math/frontend/canonical', function( $url ) {
    	if ( is_page( 'PAGE_ID' ) ) {
    		return''; // Remove Canonical URL. Replace PAGE_ID with the ID of the page you want to remove canonical.
    	}
    
     if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
    		$url = $url . '?' . $_SERVER['QUERY_STRING'];
      }
    	return $url;
    });
    

    Hope that helps. Thank you.

    Thread Starter oneray

    (@oneray)

    1) Great, it works now.

    2) concerning adding the first H2 in the meta title (just before the already added title) for this same page >> /shop , for dynamically created content >>
    https://www.online-ebook-download.com/blog/shop?cs_category=251

    including all the categories (more than 200) within it:
    /shop?cs_category=1
    /shop?cs_category=2
    /shop?cs_category=3
    etc..

    is there a way to do this ??!

    to prevent duplicate titles for 200+ category pages, is it worth it from SEO perspective ?
    will it be server intensive? no load on the server ?!

    MyThemeShop

    (@mythemeshop)

    Hello @oneray

    Can you please try with the following filter?

    add_filter( 'rank_math/frontend/title', function( $title ) {
        if ( ! is_page( 'PAGE_ID' ) || ! isset( $_GET['cs_category'] ) ) {
            return $title;
        }
    
        $term = get_term_by( 'id', $_GET['cs_category'] );
        if ( is_wp_error( $term ) || empty( $term ) {
            return $title;
        }
        
        return $term->name . ' - ' . $title;
    });

    Hope that helps. Thank you.

    Thread Starter oneray

    (@oneray)

    Not working !! it gave site-wide error >>
    Parse error: syntax error, unexpected ‘{‘ in /…../blog/wp-includes/functions.php on line 6131

    should I replace anything here? I just pasted this exact code (except PAGE_ID)..

    • This reply was modified 6 years ago by oneray.
    MyThemeShop

    (@mythemeshop)

    Hello @oneray

    Please try with the following code:

    add_filter( 'rank_math/frontend/title', function( $title ) {
        if ( ! is_page( 'PAGE_ID' ) || ! isset( $_GET['cs_category'] ) ) {
            return $title;
        }
    
        $term = get_term_by( 'id', $_GET['cs_category'], 'product_cat' );
    
        if ( is_wp_error( $term ) || empty( $term ) ) {
            return $title;
        }
    
        return $term->name . ' - ' . $title;
    });

    Please stay advised that product_cat is a taxonomy name. If you are using a different taxonomy, then please tell change the name accordingly.

    Hope that helps. Thank you.

    Thread Starter oneray

    (@oneray)

    not working ..

    please visit this link, this is one of 217 dynamically created pages (pulled from a third party server) within this one page: /shop >>
    https://www.online-ebook-download.com/blog/shop?cs_category=166

    I just want to add this: ? Category: Personal Finance
    automatically before the already added meta title.. and similarly for all the other pages..

    from page source you can find this >>
    <h2 class=”cs_plugin_title”>» Category: Personal Finance</h2>

    If it’s complicated please forget about it.

    MyThemeShop

    (@mythemeshop)

    Hello @oneray

    To assist you better, can you please open a new support ticket here?
    https://community.mythemeshop.com/forum/23-rank-math-free/

    You do not need to register separately for the forums, you can just log in to your member account on MyThemeShop, and you will be logged in automatically in the community forums. Or, you can log in with your MyThemeShop username and password on the forum too.

    Looking forward to helping you. Thank you.

    MyThemeShop

    (@mythemeshop)

    Hello,

    Since we did not hear back from you, we are closing this ticket.

    Please feel free to open a new one if you need any further assistance.

    We are here to help. Thank you.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Query string parameters in canonical URLs, and First H2 in meta titles’ is closed to new replies.