Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #201661

    Hi there,

    I am using the Enfold Avia ‘Blog Post’ content element to display posts from categories. For single post pages, I would like to change the default title on single.php blog pages from ‘Blog – Latest News’ to the category in which the post belongs.

    I have copied single.php to my child theme to edit, and understand I need to change the line:
    $title = __('Blog - Latest News', 'avia_framework'); //default blog title
    to use something like this instead:
    <?php the_category(' '); ?>
    but I’m just not quite sure if that is correct/where to put it/how to get it to work and keep the existing formatting. Your guidance is appreciated!
    – Jill

    #201899

    Hey Jill!

    Try the following:

    $title = get_the_category();
    

    Best regards,
    Josue

    #202076

    Hi Josue,
    Tried that and it returns the text “Array” rather than the category. Other ideas? thanks, Jill

    #202184

    Hi,

    Can you create an administrator account and post it here as a private reply?

    Regards,
    Josue

    #202185
    This reply has been marked as private.
    #202240

    Hey Jill!

    The server user didn’t work. i can’t access your site.

    Best regards,
    Josue

    #202278
    This reply has been marked as private.
    #202527

    Hi!

    Try to replace

    
    $title = __('Blog - Latest News', 'avia_framework'); //default blog title
    

    with

    
    $categories = get_the_category();
    $title = '';
    if($categories){
    	foreach($categories as $category) {
    		$title .= $category->cat_name . ' ';
    	}
    }
    

    Best regards,
    Peter

    #202599

    Thank you, Peter, that worked perfectly!
    Regards, Jill

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Change the title "Blog – Latest News" on single to category’ is closed to new replies.