Avatar of John H
John H
Flag for United States of America asked on

Wordpress - Adding an if/else Conditional Argument in a Post Template

Hi All,

I have a Wordpress site that relies on posts having tags - its important to the categorization of the site.

I'd like to drop in a conditional argument in single.php such that if the post has no tags, that it echoes some content on the post (essentially, asking site visitors to suggest some tags in the comments section that i can later update the post with).

This code is not correct, but I hope it captures the essence of what I'm trying to do

	<?php if ( has_tag('none/null' ) { echo 'This page has no tags; please add tags in the comments section' ; } else { echo '' ; } ; ?>

Open in new window

Thanks in advance!!

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
John H

Awesome Dmitri - It works!!  Just needs to be styled a bit - Thank You Much!
John H

Quick question Dmitri - I'm editing the core files of the parent theme.  Should I have used a function in the childtheme instead?  Thx.

Yes, surely.
Otherwise you will lost all your changes after upgrade of your parent theme.
(And upgrades are vital as they may deal with security.)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck