Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Center area post/pages (http://forum.bytesforall.com/forumdisplay.php?f=32)
-   -   Conditional PHP issue (http://forum.bytesforall.com/showthread.php?t=5804)

MyJourneytoMillions Feb 9, 2010 06:16 PM

Conditional PHP issue
 
I want to add a text link above the title of the posts in a specific category, so I searched the forums and found some great stuff so I used the code

HTML Code:

<?php is_category('taxes') ?>
</p>
Why pay, use <a
href="http://www.hrblock.com/">
free tax filing </a> from H&R Block
</p>

taxes is the slug, but I also tried the cat Id which was 29. It works to put the text link where I want it but for all categories not just the taxes one.

You can check out the problem at http://www.myjourneytomillions.com

Any thoughts would be appreciated, I know I am doing something stupid

juggledad Feb 10, 2010 05:42 AM

This will explain it:
is_category() - When any Category archive page is being displayed.
is_category('9') - When the archive page for Category 9 is being displayed.

in_category('5') - Returns true if the current post is in the specified category id. read more

MyJourneytoMillions Feb 10, 2010 08:16 AM

JD,

Thanks for the response, I saw that on Codex but still couldn't figure it out. I used the following code
HTML Code:

<?php is_category('29') ?>
Why pay, use <a
href="http://www.hrblock.com/">
free tax filing </a> from H&R Block

But it is showing up on every category archive page

So it isn't on the post page
http://www.myjourneytomillions.com/post.png

It is on the taxes page:
http://www.myjourneytomillions.com/taxes.png

But it is on another category as well:
http://www.myjourneytomillions.com/wrong.png

Any thoughts?

juggledad Feb 10, 2010 09:37 AM

you need to use IN_category not IS_category

juggledad Feb 10, 2010 11:21 AM

where did you put this code?
You also mention that 'taxes' is the slug, is it a category for that post also?

MyJourneytoMillions Feb 10, 2010 01:09 PM

I put the following code:

HTML Code:

<?php in_category('29') ?>
Why pay, use <a
href="http://www.hrblock.com/">
free tax filing </a> from H&R Block

Into Kicker Multi Post Pages

I am looking for the link to be present in only when a person is looking at the taxes category

juggledad Feb 10, 2010 03:11 PM

you need an IF and a closing '?>' to end the php so your statement will be
HTML Code:

<?php if (in_category('29')) {
echo 'Why pay, use <a href="http://www.hrblock.com/"> free tax filing </a> from H&R Block'; } ?>



All times are GMT -6. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.