Q&A - theme shows different title

My theme (RT-18) shows post's title on the header, but it won't match the Q&A titles on the main pages. Is it possible to check if it's a q&a page and hide or change the title ?
On "Ask a Question" it shows the last blog post of the site
http://smartchoose.info/lib2/questions/ask
one the main page it shows the last question's title:
http://smartchoose.info/lib2/questions

  • Sajid

    Hi @Dan Mayzlish,

    Hope you are doing good today :slight_smile:

    To make sure its not a bug, I tested it on my own site and its working just fine for me. For me on ask a question page it just displays the site title. On questions page it displays the page title instead of last question name. I tested on WordPress 4.4 and TwentyFifteen theme.

    It depends on your theme how they handles the titles. Please switch your theme to default one then check if that makes any difference.

    To make sure we are on same page, I am assuming you are referring to title tag in head section that appears on top of the browser as seen in attached screenshot.

    Hope that helps! If you still need assistance, please don't hesitate to ask.

    Take care and have a nice day :slight_smile:

    Kind Regards,
    Sajid J

  • Sajid

    Hi @Dan Mayzlish,

    Hope you are doing good today :slight_smile:

    I am sorry for confusion. Yes, its a theme compatibility issue and not Q&A issue.

    I am assuming that you are using archive page and you or developer used the_title() or get_the_title() function to display the title of current page like what we normally does on actual WordPress pages or WordPress posts.

    But questions is not an actual page and is a post archive page to list custom posts so the default query is for custom posts instead of page. While the loop runs and each time creates $post object (from where the function gets the title) and override each one but leave the last post object. That's why its displaying the last questions title.

    To display the post title instead of last custom post type you need to use post_type_archive_title() instead of the_title() or get_the_title() on archive.php or archive-question.php file.

    This should fix this issue, feel free to post a reply if you need further assistance.

    Cheers, Sajid

  • Sajid

    Hi @Dan Mayzlish,

    Hope you are doing good today :slight_smile:

    Well, it should not do display the sitename on its own, its mean to display the post type title only. There must be something else going on there.

    Any way create a custom archive template naming archive-question.php and just hardcode the title of the custom post type instead of the function.

    Take care and have a nice day :slight_smile:

    Kind Regards,
    Sajid J

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.