Jump to content

Archived

This topic is now archived and is closed to further replies.

LukeB

Conditional tags not working

Recommended Posts

LukeB

I am trying to get some conditional statements working on my site but for some reason the code I am using does not seem to work. From what I can tell this should work but I am having no luck.

 

It is placed in my pagelines customise plugin and that is the only plugin activated.

 

As you can see from the page the else functions shows up but I cant seem to get the if function to work.

http://www.priceofmilk.co.uk/test-page/

 

The page is set as template 5 which is the page.epsilon.php template.

The action pagelines_after_postloop is after the postloop so is_page_template should work.

if ( is_page_template('page.epsilon.php') ) {
	add_action('pagelines_after_postloop', 'your_function_name');
    function your_function_name() { ?>
    <p>Hello World!</p>
    <?php
    }
} else {
	add_action('pagelines_after_postloop', 'your_function_name2');
    function your_function_name2() { ?>
    <p>Hello World2!</p>
    <?php
    }
}

Any assitance on this issue would be appreciated.

Share this post


Link to post
Share on other sites
Simon

You cant nest php functions like that... your code should look like this:

 

add_action('pagelines_after_postloop', 'your_function_name');

function your_function_name() {

    if( is_page_template('page.epsilon.php') ) {
       echo '<p>Hello World!</p>';

    }
}

Share this post


Link to post
Share on other sites

×