I think something like this would work:
if (the_tags('Tags:','','') === false) echo 'No Tags';
Thread Starter
fath
(@fath)
Hi Otto42,
I have tried it but no difference. Still not displaying anything.
Ahh well… This should do it then:
if (empty(get_the_tags()) echo "No Tags";
else the_tags('Tags:');
Thread Starter
fath
(@fath)
Thanks. But, can you show me how should the complete code looks like? It’s kinda confusing…
What “complete code” are you talking about?
Just stick what I gave you into your theme wherever you want to display the tags.
Thread Starter
fath
(@fath)
Done it. But whenever I refresh my website to see the result, blank page appears. Check out http://www.owastudio.com and see whether you can open the website properly…
Thread Starter
fath
(@fath)
Sorry, have to replaced with normal the_tags() because people complaining they can’t visit my website. But that’s what happened. Once I put in the above code, my website just showing a blank page.
Ahh, I left off a closing parentheses. Try this new code.
if (empty(get_the_tags())) echo "No Tags";
else the_tags('Tags:');
this forum needs a built-in debugger 😉
(or at least syntax highlighting!)
Thread Starter
fath
(@fath)
Haha. By the way, i paste the new code and still having blank page. Weird?
For the code Otto42 gave above, I think you would need to add php opening and closing around it, or paste it somewhere that’s already in php.
This code below shows “No Tags here” for posts without a single tag, then it shows the posts that have tags (post title followed by the list of tags). This also illustrates the opening php, IF statement, ELSE statement, and closing php. That can be useful.
<?php
$tag = get_the_tags();
if (! $tag) { ?>
<p>No tags here. <a href="<?php the_permalink() ?>" rel="bookmark" title="Entry for <?php the_title(); ?>"><?php the_title(); ?></a></p>
<?php } else { ?>
<p>Tags here for <a href="<?php the_permalink() ?>" rel="bookmark" title="Entry for <?php the_title(); ?>"><?php the_title(); ?></a> - <?php the_tags(' ', ' | ', ''); ?></p>
<?php } ?>