I need to have all News posts show a category header (while not showing the post title). The following piece of code seems to do the job:

if($category[0]->name == 'News'){?>
    jQuery('h1.entry-title').html('<img style="width:30px; margin-top:11px; margin-right:10px" src="<?php echo home_url(''); ?>/wp-content/uploads/2015/07/news1.jpg"> News');      
    jQuery('#menu-item-11830').addClass('current_page_item current-menu-item');
<?php } ?>

However I need this to work as well with another category (HOME-NEWS). So I need some thing like NEWS, HOME-NEWS and NEWS + HOME-NEWS. I'm a bit of a noob when it comes to PHP so I would appreciate any guidance.I can't post a live example unfortunately. I am using the Avada theme and Wordpress 4.3

  • 1
    if($category[0]->name == 'News' || $category[0]->name == 'home-news' || ...)... Commented Sep 13, 2015 at 11:31
  • Thanks @MayeenulIslam. That seemed to work. I'm having another problem though - the post title flashes on for a second and then the correct content show. Happens in Chrome but not Safari. I realize this may be more jQuery now, but wondered if you had any thoughts.
    – moodyjive
    Commented Sep 13, 2015 at 12:54

1 Answer 1


As Mayeenul said in the comment you can use:

if($category[0]->name == 'News' || $category[0]->name == 'home-news') { ...

And to follow up on your comment about the title flashing in, this is because the jQuery is run after the browser has already rendered the content so there's a brief moment when it's shown before jQuery removes it. You have 2 main solutions that I can see: either set the title to display: none by default in the CSS and then let jQuery decide to show it (you could put an ELSE in your if statement for example) rather then hide it.

The other method would be to not use jQuery and instead edit the template in your child theme itself so that it's sent to the browser correct in the first place. I'd recommend this as a much cleaner way of doing it if you're comfortable editing the theme template, just make sure that you have a child theme set up for Avada, rather than changing the original theme itself and run the possibility of your changes being overwritten in future Avada updates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.