0

I'm stuck in an odd situation. I'm taking dynamic boolean value from admin panel in WordPress, and with that condition of data, I need to set another conditional statement, but when in implementation I came to know that, I've never done this.

if( get_option('on_blog_page_too') )
   if( is_home() || is_page_template('blog.php') ) :
else
   if( is_home() ) :

But as you can understand I'm getting a Parse Error:

Parse error: syntax error, unexpected 'if' (T_IF), expecting ':'...

How can I put condition over conditional statements?

4 Answers 4

1

Yor second if don't have body, and replace : with ; something like:

if( get_option('on_blog_page_too') ){
    if( is_home() || is_page_template('blog.php') ){

    }
}else{
    if( is_home() );
}
Sign up to request clarification or add additional context in comments.

1 Comment

That can be a way, but I have a huge block of items to show under each conditional, so I can't go with this way.
0

As the additional part is attached with the base conditional (the dynamic value from the back end) why not we bind them together?

if( ( get_option('on_blog_page_too') && is_page_template('blog.php') ) || is_home() ) :

So if the option is get, so do we need to match the is_page_template is blog or not. If the option is not set, our secondary condition is ready: only for home page.

1 Comment

This doesn't really answer the question. Please edit your question instead of posting an answer.
0

replace ":" with semi-colon ";"

4 Comments

I think you are out of PHP :p
Ok, didn't know that.. thank you.. so i think you're missing "endif;" at the end
and if you replace ":" with ";" your code will work.. you can try it
@FirasRassas technically, that's correct so I'll give a+1 to balance your score. But OP probably didn't post all the code that goes into that if statement so simply changing to ; will not do anything except remove the parse error
0

You're missing endif; for your inner if statements.

if( get_option('on_blog_page_too') )
  if( is_home() || is_page_template('blog.php') ) :
      // code here
   endif;
else
  if( is_home() ) :
    // code here
  endif;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.