Support » Fixing WordPress » Using is_page($pageID) on single.php when pages are using single.php?

  • Hi there,

    I’m trying to use this code on single.php to output a list of certain categories. It works fine when I use it on page.php but I thought I’d try *not* using page.php as I don’t need an extra template file as I feel I can get pages themed the way I want using just single.php.

    However this code just won’t work on single.php for the page even when page.php isn’t being used anymore.

    <?php if ( is_page(10231) ) { ?>
    <?php wp_list_categories('show_count=0&child_of=60&title_li='); ?>
    <?php } ?>

    Is it possible to use is_page($pageID) on single.php even when pages are using single.php as it’s theme file?

    I hope that my question is clear.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Ok, I think I found the answer here:

    What Template is used to Display a Particular Page?

    WordPress will look for several template files in your active Theme. The first one it finds will be used to display any given Page. WordPress will look for files in the following order:

    1. The Page’s selected “Page Template”
    2. page.php
    3. index.php

    I added the conditional statement to the index.php file and that worked. 🙂

    mmmm that just fixed it for your particular case, i am having problems using is_page() on my custom templates which i have to use for my implementation…. can we bump this up, is there a way to grab page priority? this is hurting links for me because i need the selected link to be colored so you know what page you belong to besides the title and if the is_page and is_home fail because of custom templates this will mess up your css implementation

    so i needed to be able to change divs depending on which particular page i was looking at (this was so the current page would display a different font color for the link linking to itself so you knew what page you were on, i used straight php->
    <?php if($_SERVER[‘REQUEST_URI’]==”/2.0/”) echo “<div id=’sean_override’>”; ?>

    then i did this a bunch of times so i could get every link working
    `<?php if($_SERVER[‘REQUEST_URI’]==”/2.0/blog/”) echo “<div id=’sean_override2′>”; ?>
    <?php if($_SERVER[‘REQUEST_URI’]==”/2.0/videos/”) echo “<div id=’sean_override_videos’>”; ?>
    <?php wp_list_pages(‘title_li=&sort_column=menu_order&exclude=’.get_option(‘tbf2_exclude_pages’)); ?>
    <?php if($_SERVER[‘REQUEST_URI’]==”/2.0/blog/”) echo “</div>”; ?>
    <?php if($_SERVER[‘REQUEST_URI’]==”/2.0/videos/”) echo “</div>”; ?>’

    this allows me to make the current page able to modify current page links similar to the built-in ‘current_page_item’ which won’t work for custom templates. YAY!! Let me know if there is more info needed,
    you can check out this implementation at http:/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using is_page($pageID) on single.php when pages are using single.php?’ is closed to new replies.