Page 1 of 1

Php If statements in WP

Posted: Thu Nov 18, 2010 5:02 am
by aravona
I've trawled the Wordpress forums but there isn't really an answer to my question.

I've got an If statement which uses an Id which you can call with wpsc_vargrp_id(); however it seems to want to ignore the if statement.

I echo'd the wpsc_vargrp_id and got 1, 2 and 4. Its the group using id 4 which I want to display differently with the If statement.

So I added:

Code: Select all

if (wpsc_vargrp_id() == '4') { 
Display vargrp 4 
}
else {
display all other vargrps
}
But it just ignored the if statement and just uses the else.

Since I can't get an answer on the WP forums I was hoping someone here could help :)

Regards,

Aravona

Re: Php If statements in WP

Posted: Sat Nov 20, 2010 2:17 am
by greyhoundcode
If that's your actual code up there then the problem is basically a syntax error.
aravona wrote:

Code: Select all

if (wpsc_vargrp_id() == '4') { 
    Display vargrp 4 // This isn't PHP
}
else {
    display all other vargrps // Nor is this
}
Try something like this perhaps:

Code: Select all

$result = wpsc_vargrp_id();

if ($result == 4) {
    echo '4';
}
else {
    echo $result;
}

Re: Php If statements in WP

Posted: Sat Nov 20, 2010 2:36 am
by s992
You said that you "echo'd the wpsc_vargrp_id and got 1, 2 and 4." Were all of these numbers returned in an array?

Re: Php If statements in WP

Posted: Sat Nov 20, 2010 3:56 am
by greyhoundcode
aravona wrote:I've trawled the Wordpress forums but there isn't really an answer to my question.
Doesn't this relate to the plugin made by Instinct? Maybe they've got specific support forums/IRC channels.