• Resolved webgalway

    (@webgalway)


    great plugin – I have been trying to alter the h1 heading for the categories archive listings page (for seo purposes) – I would like to add 2 words of text before each title on this page. I tried adding to the functions file something like the following (copied and pasted from another source) but nothing changes. Any help would be greatly appreciated.

    function new_cpt_archive_title($the_title){
    if ( is_post_type_archive(‘acadp_listings’) ){
    $the_title = ‘Courses in ‘ .$the_title;
    return $the_title;
    }

    return $the_title;
    }
    add_filter( ‘pre_get_document_title’, ‘new_cpt_archive_title’, 10, 2 );

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author pluginsware

    (@pluginsware)

    Hi,

    Actually, we are using custom pages for the categories archive listings page. So please send me the link to the categories archive listings page to check and update you.

    Thanks

    Thread Starter webgalway

    (@webgalway)

    Thanks for your reply, actually my mistake is not the category archive page – it is the listings category pages for example please see this link – eveningstudy.ie/course-category/business-and-accounting/ for the top I would like the heading to be ‘Courses in Business and Accounting’ thanks again..

    Thread Starter webgalway

    (@webgalway)

    If you could tell me please where the category page heading is set I will try changing from there?

    Plugin Author pluginsware

    (@pluginsware)

    Hi,

    Kindly try adding the following code to the bottom of your theme’s functions.php file.

    function acadp_custom_category_title( $title, $id = 0 ) {
        if ( ! in_the_loop() || ! is_main_query() ) {
            return $title;
        }
       
        global $post, $wp_query;
    
        $post_id = $wp_query->get_queried_object_id();      
        if ( $id > 0 && $id != $post_id ) {
            return $title;
        }
       
        $page_settings = get_option( 'acadp_page_settings' );
       
        // Change Category page title
        if ( $post->ID == $page_settings['category'] ) {        
            if ( $slug = get_query_var( 'acadp_category' ) ) {
                $term = get_term_by( 'slug', $slug, 'acadp_categories' );
                $title = 'Courses in ' . $term->name;          
            }          
        }
       
        return $title;  
    }
    add_filter( 'the_title', 'acadp_custom_category_title', 999, 2 );

    Hope this helps you

    Thanks

    Thread Starter webgalway

    (@webgalway)

    Yes it does help me very much and using that code I was able to add for locations also. Very much appreciated. Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add words to category archive title’ is closed to new replies.