title tag not working on SOME custom theme pages

#50675
  • Resolved Anonymous
    Rank Math free

    Hi there,

    rankmath is working great on our custom website on all pages.

    However, on the product pages (custom wordpress theme – OPS) it gives the same title tag on ALL pages.

    If I turn off rewrite title in rankmath settings then the title is this:
    3D Foil Business Cards which is great! I want to pull the product title like this but for rankmath

    As I mentioned the product pages are generated by a custom OPS system running behind wordpress BUT the title field from these products should be accessible to the rankmath title rewrite

    Please advise/guide/help how to get rankmath to rewrite the custom product page titles.

    Many thanks.

    Kind regards

    • This topic was modified 5 years, 1 month ago by .
    • This topic was modified 5 years, 1 month ago by .
    • This topic was modified 5 years, 1 month ago by .
Viewing 15 replies - 1 through 15 (of 16 total)
  • Anonymous
    Rank Math free

    Hello,

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

    Thank you.

    Anonymous
    Rank Math free

    Hello,

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

    Thank you.

    Alberto
    Rank Math business

    Hello,

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

    Since it is not using the default WordPress system (it doesn’t even add a custom post type, it uses a page template and modifies it dynamically), you will need to use the Rank Math API Hooks to modify the title.

    This is the filter to modify the title:

    /**
     * Filter to change the page title.
     * 
     * @param string $title
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
    	return $title;
    });

    You will need to modify it to check if the function is running on the template page (that is the page called ‘print’) and if it is there you will need to access the OPS title, OPS parent category, and OPS subcategory. Finally, you just need to add them and return the new title.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Anonymous
    Rank Math free

    Hi again, just wondering if anyone has had time to take a look at this. We are so appreciative of all your work and the plugin but just need some assistance on this one! 🙂 Hope all is well.

    Michael Davis
    Rank Math pro

    Hi there,

    Apologies for the delay.

    The code works to remove all the rest of the Rank Math tags except the title.
    I’ve added the following snippet to your theme which seems to do the trick:

    /**
     * Filter to change the page title.
     * 
     * @param string $title
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
    	if( is_page('12')) {
    		return false;
    	}
    	return $title;
    });

    Kindly check and let us know how this goes. Thank you.

    Anonymous
    Rank Math free

    Hi there,

    Thank you! Works great.

    Apart from the title on /print page

    it just says Print Shop – it is not pulling from wp page title and I have no idea where “Print Shop” is coming from.

    Please could you take a look to see why this page’s title tag is not pulling through correctly?

    Kind regards

    • This reply was modified 5 years ago by .
    Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank Math today.

    I can’t seem to find the specified page, would you please share a link to the page so we can have a look further.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Anonymous
    Rank Math free

    Hello,

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

    Thank you.

    Anonymous
    Rank Math free

    Please check top line of sensitive data for the /print page URL

    Anonymous
    Rank Math free

    Hi there,

    Sorry to bother you again but have you had a chance to look at the URL top line in the: Sensitive Data.

    It is literally just this one page for which the title isn’t pulling from wordpress title or ideally rankmath title on that page.

    The main product page: mysite.com/print (live URL in sensitive data) shows a title tag = “Print Shop” – I have no idea where this is coming from.

    The product page: mysite.com/print/product1 – are pulling the correct title from the custom backend screens but it is just this page: mysite.com/print that I want to pull rankmath title OR the wordpress title.

    All these pages use the same template therefore having the same page ID which is problematic with the code you have suggested – although it works very well for all other pages! 🙂

    Thank you so so much for the help. Appreciate it.

    • This reply was modified 5 years ago by .
    Michael Davis
    Rank Math pro

    Hello,

    Thank you for the follow up.

    I have checked your page and the Rank math is not generating any meta in your page. The page title seem to becoming from your theme or one of your plugin as you can see in this screenshot:
    screenshot

    Looking forward to helping you. Thank you.

    ​​​​​​

    Anonymous
    Rank Math free

    Thank you for the reply.

    Yes I can see that.

    So please are you able to help me pull the correct title from the /print page that works with the code you have added to functions.php

    Anonymous
    Rank Math free

    i fixed it 🙂

    Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank Math today.

    We are glad you were able to find a fix for it.

    Please do not hesitate to let us know if you need our assistance with anything else.

    Anonymous
    Rank Math free

    Thank you. I just changed the /print page to another page so that the ID of that page would not be 12.

    Hopefully the title compatibility can be improved in the future with more development.

    Kind regards

Viewing 15 replies - 1 through 15 (of 16 total)

The ticket ‘title tag not working on SOME custom theme pages’ is closed to new replies.