Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #662168

    Hi,

    I am currently using this code to replace the default post tile “Blog – Latest News” with the actual post title, works great, how can add the post published date to that now?

    /*
    *Replace the default “Blog – Latest News” title	
    *http://kriesi.at/documentation/enfold/replace-the-default-blog-latest-news-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'] = get_the_title($id);
            $args['link'] = get_permalink($id);
            $args['heading'] = 'h1';
        }
    
        return $args;
    • This topic was modified 8 years, 5 months ago by yingyang.
    #662175

    Hey kilimats!

    Please use the code as following

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
    $my_date = the_date('', '<span>', '</span>', FALSE);
    
        if ( $args['title'] == 'Blog - Latest News' )
        {
            $args['title'] = get_the_title($id) .' - '. $my_date;
            $args['link'] = get_permalink($id);
            $args['heading'] = 'h1';
        }
    
        return $args;
    }

    Best regards,
    Yigit

    #662263

    Beauty ! worked, how can i add a few words before like POST FOR then date and post title after?

    #662293

    Hey!

    Please change the code to following one

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
    $my_date = the_date('', '<span>', '</span>', FALSE);
    
        if ( $args['title'] == 'Blog - Latest News' )
        {
            $args['title'] = '<strong>POST FOR: </strong>'. $my_date .' - ' .get_the_title($id);
            $args['link'] = get_permalink($id);
            $args['heading'] = 'h1';
        }
    
        return $args;
    }

    Regards,
    Yigit

    #662296

    nice im learning thanks ! now if i wanted to make the post title STRONG, how would i format that, tried <strong>.get_the_title($id)</strong> but the site crashed

    last question promise

    edit: noticed a bug,the google chrome tab doesnt display properly, on the private link below, the tab shows “- 0” but the post title is – $350 – (POSTED ON: JULY 5, 2016)

    • This reply was modified 8 years, 5 months ago by yingyang.
    #662464

    Hi,

    Try this instead:

    $args['title'] = '<strong>POST FOR: </strong>'. $my_date .' - <strong>' .get_the_title($id). '</strong>';
    

    Thanks,
    Rikard

    #665867

    THat worked for the google chrome tab title but now the post title doesnt show the date anymore, see private for example

    #665939

    Hey!

    It does work totally fine on my local installation – http://i.imgur.com/7bm9xQV.png
    Can you please try de-activating all active plugins, flush cache and check if that helps?

    Best regards,
    Yigit

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