Forums

file_exists to incorporate alternate sidebar (1 post)

  1. robahas
    Member
    Posted 3 years ago #

    Greetings,

    I'm using the php function file_exists to say: If a sidebar file exists with the name of the page title use that sidebar instead of the default. It worked on my wamp server but upon uploading to the remote server (I think it is linux) it broke. I've tried variations ad nauseum, thinking that it has something to do with the way the server parses the URL, and this is the latest one I'm working with.

    <?php
    $parent_title = get_the_title($post->post_parent);
    $parent_title = strtolower($parent_title);
    $sbar_name = '/wp-content/themes/digg-3-col/sidebar-$parent_title.php';

    if (file_exists($sbar_name))
    { get_sidebar('$parent_title'); }
    else
    { get_sidebar(); }
    ?>

    All I get is the default sidebar even though I have a sidebar file called sidebar-bellingham.php in the theme folder. The site is http://www.detailswa.com Any thoughts? Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.