Basic PHP & HTML help

Discussion in 'Web Design and Development' started by sbryan, Sep 21, 2009.

  1. sbryan macrumors member

    Joined:
    Jun 6, 2007
    #1
    Well, I did have a sidebar.php file for my Wordpress theme, but it turns out that sidebar needs to be somewhat dynamic.

    I had just done this to call the PHP file from my homepage:
    PHP:
    <?php include_once "sidebar.php"?>
    I made the sidebar.php file into a custom Wordpress Page template, and I have function calls to fill in the information I need:

    PHP:
    <?php the_content(); ?>
    PHP:
    <?php the_meta(); ?>
    Is there a way to call the PHP file now?

    PHP:
    <?php include_once "http://website.com/sidebar.php"?>
    and

    PHP:
    <?php include_once "http://website.com/sidebar"?>
    Do not work. They error out.

    Do I even need PHP reference, can I just reference that extension-less link that Wordpress creates(the latter)?
     
  2. rowsdower macrumors 6502

    Joined:
    Jun 2, 2009
    #2
    Try this:

    PHP:
    <?php include_once "/sidebar.php"?>
     
  3. Wee Beastie macrumors regular

    Joined:
    Aug 20, 2007
    Location:
    In the snow with Rosebud
    #3
    If rowsdower's tip doesn't work, I have another suggestion. In my experience, if sidebar.php is at the root of your theme folder you should just need this:

    Code:
    <?php get_sidebar(); ?>
    If that doesn't work, try this:

    Code:
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    The latter is what I use if I have multiple sidebar templates that I need use. Replace sidebar.php with the name of your template file of course...


    PS. you know if you hit a rowsdower you get to keep it...:D
     
  4. rowsdower macrumors 6502

    Joined:
    Jun 2, 2009
    #4
    The meat's a bit gamey...
     

Share This Page