• When I enter my site, the dynamic includes work fine.

    If I click one of my blog subject titles, it leads to a directory that is wordpress/dynamic link example. Then, when I try access other pages in my site from then on, the dynamic includes don’t work. It would be redundant to install all my pages into my wordpress folder.
    I suppose it’s a bit of a broken links situation…

    Do you need a clarification? Better yet, how can I resolve this?
    Thanks!

    https://cosmosnow.net

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter cosmosnow

    (@cosmosnow)

    Oh.

    Mainly, my other pages are in my default themes folder, so that’s where I have the dynamic includes code – in the index of my default theme.

    Either use full (not relative) paths or put all of your php include files into your theme folder and use this format to include them:

    <?php include (TEMPLATEPATH . '/my-include.php'); ?>

    Thread Starter cosmosnow

    (@cosmosnow)

    Where should I put that format? Into my themes index page?

    Insert this code into one or more of your theme’s template pages (index.php, single.php, page.php, etc.). Where you put it depends on where you want it to appear.

    Thread Starter cosmosnow

    (@cosmosnow)

    How would I use full paths? Should I just directly upload the content inside my WordPress directory into the my site’s root directory?

    Thread Starter cosmosnow

    (@cosmosnow)

    here’s the code I have in my default themes index:

    <?php get_header(); ?>
    <?php if (isset($_GET[‘x’])) {
    if (strpos($_GET[‘x’], “/”)) {
    $dir = substr(str_replace(‘..’, ”, $_GET[‘x’]), 0, strpos($_GET[‘x’], “/”)) . “/”;
    $file = substr(strrchr($_GET[‘x’], “/”), 1);
    if (file_exists($dir.$file.”.php”)) {
    include($dir.$file.”.php”);
    } else {
    include(“pages/default.php”);
    }
    } else {
    if (file_exists(basename($_GET[‘x’]).”.php”)) {
    include(basename($_GET[‘x’]).”.php”);
    } else {
    include(“pages/default.php”);
    }
    }
    } else {
    include(“pages/default.php”);
    } ?>

    <?php get_footer(); ?>

    pages/default.php is a relative path. Either put the includes into your theme folder and use the TEMPLATEPATH code or use a full path (one that starts with http).

    Thread Starter cosmosnow

    (@cosmosnow)

    Honestly, I appreciate your effort! The full path method does not work.
    I don’t understand what you mean by putting the “includes into [my] theme folder”… define “includes”? Do you mean my header.php/footer.php?
    I’m more or less new to PHP and the exact terminology.
    I apologize!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How can WP remain consistent with my dynamic includes?’ is closed to new replies.