0

I'm just working on a "quick" change to the blog-entry-subtitle of specific posts in a category on my wordpress website. I'm hoping to have "Published in Orchard and Vine Magazine on:" instead of "Posted on:".

You'll see that the page I'm trying to customize is here

<?php if ( is_category('Legal Libation Columns') ) : ?>
    <h2 class="blog-entry-subtitle">Published in Orchard and Vine Magazine on: <?php the_time('F j, Y'); ?></h2>
<?php  else: ?>
    <h2 class="blog-entry-subtitle">Posted on: <?php the_time('F j, Y'); ?></h2>
<?php endif; ?>

GREAT! I love it. However once you click on one of those posts to read more it converts the blog-entry-subtitle back to the "Posted on:" as now you aren't in the specific category anymore.

I would like the "Published in Orchard and Vine Magazine on:" instead of "Posted on:" for all posts with a category and tag of Legal Libation Columns. So then I try this.

<?php if (is_category('Legal Libation Columns') && has_tag('Legal Libation Columns')); ?>    
    <h2 class="blog-entry-subtitle">Published in Orchard and Vine Magazine on: <?php the_time('F j, Y'); ?></h2>
<?php  else: ?>
    <h2 class="blog-entry-subtitle">Posted on: <?php the_time('F j, Y'); ?></h2>
<?php endif; ?>

However I get a weird white screen of nothing? enter image description here

How do I have it so that any post with the tag Legal Libation Columns always has that specific blog-entry-subtitle without giving me an error?

3
  • What do you mean by breaking the site, according to me and many others, this means a white screen of death. What debug info do you get. You are saying "category and tag", so your operator is wrong, || should be && Commented Jul 22, 2014 at 4:40
  • I had used && but it gave me a white screen? See updated question.
    – kia4567
    Commented Jul 22, 2014 at 8:33
  • In the first line ; is in the end. There should be :. This is causing white screen of death. <?php if (is_category('Legal Libation Columns') && has_tag('Legal Libation Columns')): ?> Commented Jul 22, 2014 at 8:58

1 Answer 1

1

I think your problem lies in is_category(). This conditional check if you are on a category page, not if a post belongs to a category.

To check if a post belongs to a category, you should be using has_category

So your conditional statement should be

<?php if (has_category('Legal Libation Columns') && has_tag('Legal Libation Columns')): ?> 

EDIT

Thanks to @Nilambar, there is a syntax error as well in your code as he said

Here are some tips

  • Don't use : and endif. If makes code difficult to read and it is not code editor friendly. Rather use curly brackets {}

  • When developing themes and plugings, or just make changes to a site, set debug to true. Such errors is easy recognizable with debug set to true. Please take the time and read Debugging in Wordpress

  • Always indent your code properly to make it easier to read and follow

3
  • Thanks for all of this. Will be fixing it up with your suggestion as well. One more thing, i there a way to have the Previous and Next buttons only go through the specific category as opposed to both the category and the blog?
    – kia4567
    Commented Jul 22, 2014 at 15:21
  • My pleasure. Sure, although it is gong out of scope for this question :-). Go and have a look at next_post_link and previous_post_link Just set $in_same_term = false argument to $in_same_term = true Commented Jul 22, 2014 at 15:26
  • Thanks. I started a new topic for more guidance on the post links - wordpress.stackexchange.com/questions/155486/….
    – kia4567
    Commented Jul 23, 2014 at 3:21

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.