tranceplant
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: simple PHP question^Hey jay
that code was exactly what I was looking for. I feel i’m learning a bit here…. But yeah I wish I knew PHP like you guys.
<?php
foreach((get_the_category()) as $category) {
if ( $category->cat_name == ‘FOOTBALL’ ) {
echo “hello world”;
}
}
?>Thanks again for your time and understanding. Your explaination was very good.
I’ll leave you guys alone now ??
Forum: Fixing WordPress
In reply to: simple PHP questionoh thanks. I see what you did here. It does work.
but in both cases HELLO WORLD would appear.
What I was looking for is basically to have HELLO WORLD in all the posts that ‘contains’ FOOTBALL. So SOCCER alone wouldn’t have the HELLO WORLD.
Thanks for your patience and time!
Forum: Fixing WordPress
In reply to: simple PHP questionoh yea, that did the trick. The only thing I was missing was the apostrophe.
Thanks a million.
I found what I was looking for and it’s perfect like that, but I’ll push my luck a little further.
I just realize that if I have 2 categories selected it wouldn’t work. Not a big deal, but would it be easy to have it say. if the name category is simply one of the many selected. Meaning, if I have football and hockey selected as a category the HELLO WORLD would still work.
Ok if it’s easy to do that would be great, if not, it will be all good.
Thanks again guys ??
Forum: Fixing WordPress
In reply to: simple PHP questionThanks for your help guys, I appreciate it.
Like I said I am not a pro with PHP, to be honest I played around with this code and it worked, so my method is not exactly out of the book.
What I am looking to do here is when the user clicks a category that is named “football” for example. I want to write “hello world”
So let me write it the way I see it
<?php
$category = get_the_category();
if ( $category[0]->cat_name == FOOTBALL )
{
echo “hello world”;
}
?>^I know this is wrong, but when a user creates a post, he simply needs to click the category FOOTBALL and the HELLO WORLD would show on the index page when reading.
I hope that make sense.
cheers
Forum: Fixing WordPress
In reply to: simple PHP questionHUmm, seriously I am not sure I understand the content of the link. Like I said I am a beginner.
I am not looking to echo the category name, I just want to use it in a “if” statement.
Forum: Fixing WordPress
In reply to: Linking to actual blog post from sidebaryou know you should post the solution when you figure it out. Please