Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

if else statement works only as admin WordPress

  • REFUNDED

I try to set up conditional tabs on a non cached post-page with custom post type.

I get the post-meta with ($post->external) what work fine if i echo the value.

Everything work as it should when i'm logged in.

In frontend modus and not logged in Tab3 is never show and tab2 do not disappear.

My Code:

<ul class="tabs" >
<li><a class="tabs" href="#tab1">Tab 1</a></li>
<?php echo (($post->external) == true ? '' : '<li><a class="tabs" href="#tab2">Tab 2</a></li>'); ?>
<?php echo (($post->external) == true ? '<li><a class="tabs" href="#tab3">Tab 3</a></li>' : ''); ?>
</ul>


Any Ideas?

Answers (4)

2014-10-08

Bob answers:

can you provide url or access?


Bob comments:

what will be return value of $post->external ?
true or false Boolean value?


Peter Brain comments:

Yes, Boolean


Bob comments:

It is possible that you might be loading some tabs related jquery like jquery ui when you are logged in.

do you have any javascript error in your console?

2014-10-08

Luis Abarca answers:

Ummm, looks like both tabs are using the same value, maybe both can be mixed into one if.

Can you paste the full template ?

2014-10-08

Sébastien | French WordpressDesigner answers:

use this code

<ul class="tabs" >

<li><a class="tabs" href="#tab1">Tab 1</a></li>

<?php echo (($post->external) == true ? '<li><a class="tabs" href="#tab3">Tab 3</a></li>' : '<li><a class="tabs" href="#tab2">Tab 2</a></li>'); ?>

</ul>


Peter Brain comments:

This work but only when i'm logged in.


Sébastien | French WordpressDesigner comments:

can you provide url ?


Peter Brain comments:

Sorry this is not possible

2014-10-09

Arnav Joy answers:

Hello Peter ,
Can you provide full code of the file ?