Jump to content

eddioot

New Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

eddioot's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Wow it really was that simple Thank you very much!
  2. Hi all, i am fairly new with php and i am running into a problem with a php function. It is very basic but i've got something wrong here. It is a function in wordpress that needs to analyze the post and extract the category. For every category another value needs to be returned. My code is: function postimage($post_id){ $category = get_the_category( $post_id ); $id = $category[0]->cat_ID; if ( $id = 45 ){ $link = 'This is category 45'; } else { $link = 'This is not category 45 '; } return $link; } There are 2 strange things happening: 1. The first statement is always true. Even if the category id is not 45 it still returns the first $link. 2. If i return the variable $id after the if statement it returns als 45. If i do it without the if statement it returns correct. The 2 problems are obviously related but i don't understand what i'm doing wrong. Please help
  3. Ok, i misunderstood your suggestion and indeed it works. Sorry and thanks man, no need to get angry
  4. Hi premiso, thanks for your repsonse. My problem seems to be that the bigger than does not work. So >= is not resolving. When i use = it does resolve.. I need to create the function so i can return levels when the value is between 1 - 10 and another level when it is between 11 - 20 and so on.
  5. Hi all, i think i am making a really stupid mistake but i have a problem with my php function that i do not get. My function is: function user_level($userlevel){ if($userlevel = 0){ $level = test; } elseif($userlevel >= 1){ $level = test1; } return $level; } In the cases i tried it on the userlevel is way higher than 1, but nothing returns when i echo the function. Whenever i change the >= to = and the exact number, it works fine. So the following does work: elseif($userlevel = 767){ $level = test1; } Am i doing something really stupid here?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.