Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #664089

    Hi,

    So first I will start by saying that I have added the code to the functions file to change the title of the blog from “Blog – Latest News” to “Insights”. I have done that with this code.

    `add_filter(‘avf_title_args’, ‘fix_single_post_title’, 10, 2);
    function fix_single_post_title($args,$id)
    {
    if ( $args[‘title’] == ‘Blog – Latest News’ )
    {
    $args[‘title’] = Insights;
    $args[‘link’] = get_permalink($id);
    $args[‘heading’] = ‘h1’;
    }

    return $args;
    }`

    With that being said the main reason for my question is that I have also created a custom post type called counselors but now on the counselors single pages it’s also displaying that same “Insights” header. I did a search like normal to see what I can find and I found this thread.

    https://kriesi.at/support/topic/custom-post-types-and/

    She was basically looking to do the same thing as me so I tried to follow suit but im having no luck. Here is the code im using to try and change my custom post type title.

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title_2($args,$id)
    {
        if ( is_singular('post') || is_singular('counselors') )
        {
            $args['title'] = get_the_title($id);
            $args['link'] = get_permalink($id);
            $args['heading'] = 'h1';
        }
    
        return $args;
    }

    I changed the the function name so it’s not the same as my first function to change my blog title and I put in my CPT slug where they said to do it but yea….its just not working.

    Any help would be great.

    Thanks
    -Dan

    #664869

    Hi,

    Can you please create us a WordPress administrator account? post it here as a private reply.

    Regards,
    Josue

    #664875

    Here you go, thanks for the help

    #664886

    Hi,

    You were missing a 2 in the second filter:

    add_filter('avf_title_args', 'fix_single_post_title_2', 10, 2);
    

    Best regards,
    Josue

    #671545

    Hi,

    So I thought I had this working right but it turns out I don’t.

    When you are on this page.

    The title is right, but when you click into a post it says this.

    This is the title for my CPT I added in.

    Any guidance?

    Thanks
    -Dan

    #671635

    Hi,

    The second link you posted is returning a 404 error.

    Best regards,
    Josue

    #671656

    Odd, i am not getting that

    #671850

    Hi,

    What title should be there? the login access you provided aren’t working.

    Best regards,
    Josue

    #671852

    The same title that is on the first page. Insights is what the blog index page says but when you go into the blog post page it goes back to Counselors.

    Here is the code

    // Change Blog Title 
    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
        if ( $args['title'] == 'Blog - Latest News' )
        {
            $args['title'] = Insights;
            $args['link'] = get_permalink($id);
            $args['heading'] = 'h1';
        }
    
        return $args;
    }
    
    // Change CPT Title
    add_filter('avf_title_args', 'fix_single_post_title_2', 10, 2);
    function fix_single_post_title_2($args,$id)
    {
        if ( is_singular('post') || is_singular('counselors') )
        {
            $args['title'] = Counselors;
            $args['link'] = get_permalink($id);
            $args['heading'] = 'h1';
        }
    
        return $args;
    }

    I just added another custom post type that im going to need to do this too also.

    I have it working here This is a custom post type post page, there is not index page for this post type.

    But here are two other CTP that I need it working on correctly

    CTP for Success Stories

    This is the main default wordpress “post” I just have changed the name of it

    Default post with name changed

    So technically i am using the default “post” with a changed name and also have two custom post types

    #671870

    Hi,

    Instead of those snippets i’d suggest using something like this:

    add_filter('avf_title_args', 'fix_single_post_title_2', 10, 2);
    function fix_single_post_title_2($args,$id)
    {
        if ( is_singular('post') || is_page(12) ) { // 12 being Page ID of the blog index
            $args['title'] = 'Insights';
        } elseif ( is_singular('counselors') ) {
        	$args['title'] = 'Counselors';
        } elseif ( is_singular('another_ctp') ) {
        	$args['title'] = 'Another CPT';
        } else {
        	$args['title'] = 'Default Title';
        }
    
        return $args;
    }

    Best regards,
    Josue

    #671882

    So I think this might be a set in the right direction but after i did this all the titles of my other pages changed to Default Title? They need to remain the title given to them.

    Like this one would be “About Us”

    About Us Page

    #672054

    Then simply leave that part empty:

    }else{
    }

    Best regards,
    Josue

    #672060

    Perfect. Thank you.

    #672064

    You are welcome, glad to help :)

    Regards,
    Josue

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.