Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress conditional statements not working
    text
    copied!<p>I'm setting up some conditional statements to change my page layout for different pages. My first conditional says </p> <pre><code>if (is_page('15030')) { } </code></pre> <p>The content inside that one is for the homepage, and works perfectly. Then my next one says </p> <pre><code>elseif (is_page('Sales')){ } </code></pre> <p>And it doesn't work at all. I've tried using the page name, page ID, changing elseif to if, using in_category - nothing is showing up at all. Any idea what I should look for that could cause that? I noticed that I set up "sales" as a category of posts, and when I created the Sales page, it is automatically showing the posts from the sales category, which is what I wanted, but I'm not sure if that would be affecting it at all?</p> <p>The code is located in custom_functions.php. Here is the complete code:</p> <pre><code>function custom_template() { if (is_page('15030')) : ?&gt; &lt;!--Technology Section--&gt; &lt;div id="content"&gt; &lt;div id="post-&lt;?php the_ID(); ?&gt;" class="post_box top"&gt; &lt;a class="scroll" id="technology"&gt;&lt;/a&gt; &lt;div class="left"&gt; &lt;a href="index.php?page_id=15174"&gt;&lt;img src="../../../images/businessbee/blog/tech-bubble.gif" alt="Technology" class="bubble"/&gt;&lt;/a&gt; &lt;h3&gt;&lt;a href="index.php?page_id=15174"&gt;Technology&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Technology upgrades don't have to break the bank. From improving your hardware to streamlining your IT management, we've compiled cost-effective solutions to cover your needs. &lt;/p&gt; &lt;hr/&gt; &lt;ul class="catCount"&gt; &lt;?php $catList = wp_list_categories('title_li=&amp;show_count=1&amp;echo=0&amp;child_of=3527&amp;hide_empty=0'); $catList = preg_replace('@\&lt;li([^&gt;]*)&gt;\&lt;a([^&gt;]*)&gt;(.*?)\&lt;\/a&gt;@i', '&lt;li$1&gt;&lt;a$2&gt;&lt;span class="name"&gt;$3&lt;/span&gt;&lt;/a&gt;', $catList); $catList = ereg_replace('&lt;/a&gt; \(([0-9]+)\)', ' &lt;span class="count"&gt;\\1&lt;/span&gt;&lt;br class="clear"/&gt;&lt;/a&gt;', $catList); echo $catList; ?&gt; &lt;br class="clear"/&gt; &lt;/ul&gt; &lt;hr/&gt; &lt;a href="index.php?page_id=15174" class="allLink"&gt;View all Technology Resources&lt;/a&gt; &lt;/div&gt;&lt;!--left--&gt; &lt;div class="right"&gt; &lt;h4&gt;Featured Resources&lt;/h4&gt; &lt;?php global $post; ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?php query_posts('cat=3527'); ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;?php $categories = get_the_category(); ?&gt; &lt;?php if ( has_post_thumbnail() ) { ?&gt; &lt;a href="&lt;?= the_permalink() ?&gt;" class="box"&gt; &lt;div class="thumbnailBox"&gt; &lt;h3&gt;&lt;?= the_title()?&gt; &lt;span&gt;posted in &lt;?= $categories[0]-&gt;cat_name; ?&gt;&lt;/span&gt; &lt;/h3&gt; &lt;?php the_post_thumbnail('medium'); ?&gt; &lt;div class="overlay"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/a&gt; &lt;?php } ?&gt; &lt;?php endwhile; ?&gt; &lt;?php endif; ?&gt; &lt;?php wp_reset_query(); ?&gt; &lt;/div&gt;&lt;!--right--&gt; &lt;br class="clear"/&gt; &lt;img src="../../../images/businessbee/blog/page-div.png" alt="" class="blog-page-div"/&gt; &lt;!--SALES SECTION--&gt; &lt;a class="scroll" id="sales"&gt;&lt;/a&gt; &lt;div class="left"&gt; &lt;a href="index.php?page_id=15206"&gt;&lt;img src="../../../images/businessbee/blog/sales-bubble.gif" alt="Sales" class="bubble"/&gt;&lt;/a&gt; &lt;h3&gt;&lt;a href="index.php?page_id=15206"&gt;Sales&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Every sales team needs a solid method for tracking leads and identifying its top performers. Take a look at these great resources, designed to help maximize your conversion rate.&lt;/p&gt; &lt;hr/&gt; &lt;ul class="catCount"&gt; &lt;?php $catList = wp_list_categories('title_li=&amp;show_count=1&amp;echo=0&amp;child_of=3536&amp;hide_empty=0'); $catList = preg_replace('@\&lt;li([^&gt;]*)&gt;\&lt;a([^&gt;]*)&gt;(.*?)\&lt;\/a&gt;@i', '&lt;li$1&gt;&lt;a$2&gt;&lt;span class="name"&gt;$3&lt;/span&gt;&lt;/a&gt;', $catList); $catList = ereg_replace('&lt;/a&gt; \(([0-9]+)\)', ' &lt;span class="count"&gt;\\1&lt;/span&gt;&lt;br class="clear"/&gt;&lt;/a&gt;', $catList); echo $catList; ?&gt; &lt;br class="clear"/&gt; &lt;/ul&gt; &lt;hr/&gt; &lt;a href="index.php?page_id=15206" class="allLink"&gt;View all Sales Resources&lt;/a&gt; &lt;/div&gt; &lt;div class="right"&gt; &lt;h4&gt;Featured Resources&lt;/h4&gt; &lt;?php global $post; ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?php query_posts('cat=3536'); ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;?php $categories = get_the_category(); ?&gt; &lt;?php if ( has_post_thumbnail() ) { ?&gt; &lt;a href="&lt;?= the_permalink() ?&gt;" class="box"&gt; &lt;div class="thumbnailBox"&gt; &lt;h3&gt;&lt;?= the_title()?&gt; &lt;span&gt;posted in &lt;?= $categories[0]-&gt;cat_name; ?&gt;&lt;/span&gt; &lt;/h3&gt; &lt;?php the_post_thumbnail('medium'); ?&gt; &lt;div class="overlay"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/a&gt; &lt;?php } ?&gt; &lt;?php endwhile; ?&gt; &lt;?php endif; ?&gt; &lt;?php wp_reset_query(); ?&gt; &lt;/div&gt;&lt;!--right--&gt; &lt;br class="clear"/&gt; &lt;img src="../../../images/businessbee/blog/page-div.png" alt="" class="blog-page-div"/&gt; &lt;/div&gt;&lt;!-- post id div--&gt; &lt;/div&gt;&lt;!--content--&gt; &lt;!--End of Homepage Content--&gt; elseif (is_page('Sales')){ &lt;h2&gt;Test Content&lt;/h2&gt; } &lt;?php endif; ?&gt; </code></pre> <p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload