WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Dynamic Content in Non WP file (2 posts)

  1. buffalokill
    Member
    Posted 5 years ago #

    The Setup

    I'm messing around with a ajax technique of dynamically loading content from some includes in my theme directory, based on the content inside of a div#panel

    so i have these includes in my theme directory.

    includes/search.php
    includes/pages.php
    includes/subscribe.php

    In the header.php template I have list of direct links to these files.

    The list of links beneath the div#panel in the header template will dynamically load the content from each of those includes when clicked directly into the div#panel in the header file.

    So as i click the search icon, the search box will load up top. As i click the subscribe icon, the feed info will swap out in place of the search box, etc.

    The Problem

    The content being loaded isn't connected with WP, so template tags are not working.

    The Question

    Is there some code that I can throw into the include files, so that they'll be considered by WP as part of the template? Maybe something I can throw into my functions.php file?

    The Markup

    <div id="panel">
        <h3>Default</h3>
        <div>Default Panel</div>
    
      </div> <!--/panel-->
    
      <div id="nav">
        <ul>
          <li class="btn-pages"><a href="<?php bloginfo('stylesheet_directory'); ?>/includes/pages.php">Pages</a></li>
          <li class="btn-archives"><a href="<?php bloginfo('stylesheet_directory'); ?>/includes/archives.php">Archives</a></li>
          <li class="btn-search"><a href="<?php bloginfo('stylesheet_directory'); ?>/includes/search.php">Search</a></li>
    
          <li class="btn-subscribe"><a href="<?php bloginfo('stylesheet_directory'); ?>/includes/subscribe.php">Subscribe</a></li>
    
     </ul>
      </div><!--/nav-->
  2. buffalokill
    Member
    Posted 5 years ago #

    To answer this question for anyone else. You just need to place this code on top of the file that you want to initiate the wordpress system.

    <?php require('../../../../wp-blog-header.php'); ?>

    Or this may work as well...

    <?php require(ABSPATH . '/wp-blog-header.php'); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic