Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

Conditional PHP issue


  #1  
Old Feb 9, 2010, 06:16 PM
MyJourneytoMillions
 
46 posts · Sep 2009
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
  #2  
Old Feb 10, 2010, 05:42 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Feb 10, 2010, 08:16 AM
MyJourneytoMillions
 
46 posts · Sep 2009
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


It is on the taxes page:


But it is on another category as well:


Any thoughts?
  #4  
Old Feb 10, 2010, 09:37 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
you need to use IN_category not IS_category
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Feb 10, 2010, 11:21 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
where did you put this code?
You also mention that 'taxes' is the slug, is it a category for that post also?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #6  
Old Feb 10, 2010, 01:09 PM
MyJourneytoMillions
 
46 posts · Sep 2009
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
  #7  
Old Feb 10, 2010, 03:11 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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'; } ?>
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks

Tags
conditional, php

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: add IE css conditional comments byronyasgur Header configuration & styling 2 Apr 26, 2011 02:25 PM
issue: blank Central Panel - PHP code options stored with an \ ssokolenko New Versions, & Updating 3 Sep 15, 2009 05:29 PM
[SOLVED] Can't edit posts - edits vanish - Virus? Theme Issue? WP Issue? jfrenaye Atahualpa 3 Wordpress theme 1 Aug 4, 2009 07:14 AM
[SOLVED] Conditional Tag to exclude widget d_random Sidebars & Widgets 8 Jun 2, 2009 07:23 AM
How do I provide a conditional Widget in the sidebars? bgt Forum How-To 1 Jun 1, 2009 02:16 PM


All times are GMT -6. The time now is 11:32 AM.


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