WordPress.org

Ready to get started?Download WordPress

Forums

Custom single.php for wordpress pages such as profile.php (3 posts)

  1. jamesb4551
    Member
    Posted 4 years ago #

    OK I get how to change the single based on a category, but what if say I wanted to change the single depending on the PHP page loaded?. For example, I want a custom single.php for when register or profile.php is loaded.
    (I use a plugin to customize register/login/profile already but need more control other than just css hacks)
    So I duplicate single.php, make the necessary style changes and call it single-profile.php. Then I try did try adding to my single.php
    <?php
    if (is_page('profile.php')) {include (TEMPLATEPATH . '/single-profile.php');
    }
    else { include (TEMPLATEPATH . '/single.php');
    }
    ?>
    at the beggining of my single.php after calling the header.
    No dice...
    Any other ideas?

  2. jamesb4551
    Member
    Posted 4 years ago #

    Hmm still no solution for this, I have it in my single to load separate sidebars as well but it doesn't work either, any PHP/wordpres heads out there that can guide me in where I may be going wrong?

  3. jamesb4551
    Member
    Posted 4 years ago #

    Is there anyone that can figure out whats going wrong here?
    It works when I test it locally to bring in the other sidebar but not live, what the.....
    This is what I use locally and it works.

    <div id="sidebar">

    <?php if ( is_page('wp-login.php')) : ?>
    <?php include(TEMPLATEPATH . '/sidebar-logreg.php'); ?>
    <? else : ?>
    <?php include(TEMPLATEPATH . '/sidebar.php'); ?>
    <?php endif; ?>

    </div>

    Can anyone point out what I may be doing wrong?

Topic Closed

This topic has been closed to new replies.

About this Topic