Skip Navigation

[Resolved] toolset category page – need to change page title

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to change the Post type archive Title Meta.

Solution:

This can be done by using the Yoast SEO plugin.

To essentially achieve this please follow the instructions in the link below.
https://www.wearewibble.com/yoast-seo-how-to-change-your-wordpress-meta-title-description/

Scroll to the section "Changing the SEO Titles and Meta Descriptions for Archives"

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by stefanT-3 4 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1940737

I want to be able to change the Page Title to something else instead of "Larmbolag arkiv -" for : hidden link

I have a custom archive page as well but for some reason I seem unable to get a proper solution going.

category-larmbolag.php contents:

---

<?php
/**
* The template for displaying Archive pages.
*
* @package GeneratePress
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

get_header(); ?>

<div id="primary" <?php generate_do_element_classes( 'content' ); ?>>
<main id="main" <?php generate_do_element_classes( 'main' ); ?>>
<?php
/**
* generate_before_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_before_main_content' );

if ( generate_has_default_loop() ) {
if ( have_posts() ) :

/**
* generate_archive_title hook.
*
* @since 0.1
*
* @hooked generate_archive_title - 10
*/
do_action( 'generate_archive_title' );

while ( have_posts() ) :

the_post();

generate_do_template_part( 'archive' );

endwhile;

/**
* generate_after_loop hook.
*
* @since 2.3
*/
do_action( 'generate_after_loop', 'archive' );

else :

generate_do_template_part( 'none' );

endif;
}

/**
* generate_after_main_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_main_content' );
?>
</main>
</div>

<?php
/**
* generate_after_primary_content_area hook.
*
* @since 2.0
*/
do_action( 'generate_after_primary_content_area' );

generate_construct_sidebars();

get_footer();

#1941429

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Stefan,

Thank you for getting in touch.
You can use this filter hook below to change the text "Larmbolag arkiv "

Add this hook to your toolset custom code settings in Toolset -> Settings -> Custom Code and ensure that it is active.

add_filter( 'get_the_archive_title', function ( $title ) {

    if( is_category() ) {

        $title = single_cat_title('',false);

    }

    return $title;

});

Please try this and let me know if it helps.

Thanks,
Shane

#1941443

Thanks Shane, I added this as a Custom Code and activated it. However, I don't understand where and how I then can change the Page Title for that category page?

#1941471

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2021-02-10 at 4.02.51 PM.png

Hi Stefan,

The line below defines the category title

        $title = single_cat_title('TEST',false);

This controls anything that is displayed before "Larmbolag - " Unless you are referring to my screenshot which is something completely different that the title on the page itself. In this case you can use the YOAST SEO plugin and go to Yoast -> Search Appearance and select taxonomy, from there you can modify the taxonomy title tag.

If its the title on the page itself you can add any text to the section where you see i've added the text "Test". This will appear before "Katalog över säkerhetsföretag".

Please let me know if this helps.
Thanks,
Shane

#1941497
Skärmavbild 2021-02-10 kl. 22.32.05.png

Thanks.

I am referring to the screenshot. I use Yoast but I can't change the individual page title for that page /larmbolag/ I can set a template for the posts within that category but not the category page itself.

#1941517

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Stefan,

The only other way to individually set the title based on the current category is to use the code below.

function generate_custom_title($title) {
/* your code to generate the new title and assign the $title var to it... */
   if( is_category('Uncategorized') ) {

        $title = "cust title 1";

    }
  if(is_category('Sample')){
   $title = "Cust title 2";
  }

return $title;  
}
add_filter( 'pre_get_document_title', 'generate_custom_title', 10 );

Please note that you will need to set the titles individually for each category. Secondly you will replace 'Sample' and 'Uncategorized' with the slug of the category that you want to change the title for.

When adding this code ensure that after its added to the Toolset custom code section that you've activated it.

Thanks,
Shane

#1941933
Skärmavbild 2021-02-11 kl. 08.50.01.png

Hi,

Still doesn't work.

/S

#1942459

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Stefan,

Would you mind allowing me to have admin access to the site so that I can check on this further for you ?

Based on what you've added it should work as the exact same code works on my end.

I've enabled the private fields for your next response.

Thanks,
Shane

#1942515

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Stefan,

Thank you for the link.

I was under the impression that this was a taxonomy archive, given that it is a Post type archive you can change it here in Yoast.
hidden link

If you check the post type you can see that i've added a custom archive title "Larmbolag".

I've also verified that it works as well.

Thanks,
Shane

#1942521

Thanks, it took a while but thanks for the patience. Have a good day.