Forums

[resolved] Subpages of page - Urgent syntax help needed please (3 posts)

  1. matthisco
    Member
    Posted 4 months ago #

    HI Folks,

    Can someone please tell me how I can get this piece of code to work, I just get a blank screen when I browse to it:

    // if pageid is 157 or subpage id of 157

    `<?php if ( is_page( 157 ) || ( is_page() && $post->post_parent) : ?>

    Do something

    <?php endif; ?>

  2. Brad Markle
    Member
    Posted 4 months ago #

    Hi matthisco, it looks like you're using php's if statement with a :

    When we "clean up your code" or just look at it from a different point of view, we see:

    <?php
    	if (
    		is_page( 157 ) ||
    		(
    			is_page() && $post->post_parent
    		)
    	:
    ?>

    It looks like you're missing a closing ) on your if statement. If we add that closing ) in there, we get:

    <?php
    	if (
    		is_page( 157 ) ||
    		(
    			is_page() && $post->post_parent
    		)
    	   )
    	:
    ?>

    ... or ...

    <?php if ( is_page( 157 ) || ( is_page() && $post->post_parent) ):?>

    Keep us updated and let us know if that helps or not!

  3. matthisco
    Member
    Posted 4 months ago #

    Thanks very much that works a treat

Reply

You must log in to post.

About this Topic