• Resolved Mike Kohn

    (@rhymeswithmilk)


    Is there a way to load the same sidebar multiple times on a page, such as each time the loop iterates?

    I’d like to display each posts’ meta data next to that post. Right now I have the info displaying just fine, but it’s hard-coded in at least 4 different places (index, archive, single & category). It would be nice if I could just include a single file, i.e. a sidebar, so that making small changes would be less annoying. Right now when I use get_sidebar(), it only loads for the first post in the loop. I have also tried a general php include, but then none of the wordpress functions like get_the_time() work.

    Thanks in advance for the help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You could just use a simple PHP include

    <?php include('bloginfo(stylesheet_directory)/nameoffile.php') ?>

    Then you have nameoffile.php inside your themes folder in your loop, and it’s contents will be included in the page? Is this what you were after?

    Thread Starter Mike Kohn

    (@rhymeswithmilk)

    Hey, it worked!

    I tried that before with an absolute path to the sidebar file and it resulted in a fatal error saying the function get_the_time didn’t exist. But using a relative path worked.

    <?php include('sidebar.php') ?>

    Thanks for the help, xdesi!

    No probs ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Load same sidebar multiple times’ is closed to new replies.