Forums

Can't seem to call files from index.php (6 posts)

  1. mcbest
    Member
    Posted 2 months ago #

    Hi All,

    I'm a relative newbie to Wordpress but putting in the hours to get up and running. While trying to create a theme from scratch, I have the following problem.

    When I create a custom page that I want to call from the index.php, I just can't get the code to appear in the page. For example, I create a file named sidebar-left.php which contains just a simple <p>Test</p>. I then add <?php get_sidebar('left');?> to the index.php but when I refresh the page, there is no sign of the sidebar-left.php code when I view source.

    I've noticed that if I place the call to the sidebar-left.php within the code for the default sidebar (named sidebar.php), it appears as expected!

    Could anyone tell me why I have problems calling from within index.php?

    Incidentally, I already call header, footer, sidebar etc. from index.php and these are all appearing fine.

    Please put me out of this misery!

    Thanks,

    Jeff

  2. mcbest
    Member
    Posted 2 months ago #

    Please don't tell me this is one of my only-ever-happens-to-me problems!!!

    Jeff

  3. esmi
    Member
    Posted 2 months ago #

    There's nothing wrong with your approach, so I think it's either the placement of <?php get_sidebar('left');?> or perhaps it's being hidden by another element on the displayed page. Have you checked the page source to confirm whether your test sidebar content is being rendered?

  4. mcbest
    Member
    Posted 2 months ago #

    Hi Esmi,

    Thanks for replying. The code is not being rendered at all when I place the call within the index.php but it is rendered when I place the call within sidebar.php.

    What are the rules concerning the placement of <?php get_sidebar('left');?>? I thought it could go anywhere within the <body></body>.

    Thanks,

    Jeff

  5. mcbest
    Member
    Posted 2 months ago #

    Can anyone shed any light on my problem?

    Thanks in advance!

    Jeff

  6. t31os_
    Member
    Posted 2 months ago #

    It works for me, i just tested to be sure..

    The bottom of my index.php looks like so..

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    All i did was update the sidebar call to..

    <?php get_sidebar('left'); ?>

    Created a sidebar-left.php, placed the word test in that file, and saved.

    Fired up the page, and the word test has appeared.

    Would be helpful if i could see your index.php code.
    http://wordpress.pastebin.com/

Reply

You must log in to post.

About this Topic