WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] using a php file include in multiple multisite sites (5 posts)

  1. lisa@getcws.com
    Member
    Posted 1 year ago #

    Working with WP Multisite for one customer with 9 locations (and individual sites) and growing. I wanted to use an include to pull in the Locations (a google map plus list of locations) into each site's individual Locations page. I can't get the include to work (i can get it to work using iFrame, but well, I don't want to use iframe, rather use an include. WordPress seems to ignore the include. I'm running a child theme of 2011.

    Any suggestions? Here's the page I want to "include": http://twomaidsandamop.com/map/index.php

    and here's the page I want to "include" it on: http://greensboro.twomaidsandamop.com/location/

    and the code I've tried using is <?php include("http://twomaidsandamop.com/map/index.php"); ?>

    I know just enough to be dangerous, and appreciate any help provided.

  2. You generally can't run PHP includes in a WP page (security).

    You could do this with a page template, make a 'page-location.php' template that uses the php code.

  3. lisa@getcws.com
    Member
    Posted 1 year ago #

    It's still ignoring the include call. I added "abcdefg" into the template file and it displays the text, but ignores the include.

  4. That would be because youre not using include right.

    http://php.net/manual/en/function.include.php

    include(/full/path/to/map/index.php);

    Possibly include 'http://www.example.com/file.php?foo=1&bar=2'; woudl work, but I've never tried it.

  5. lisa@getcws.com
    Member
    Posted 1 year ago #

    I did find a solution, and here is what worked:

    <?php
       $path = $_SERVER['DOCUMENT_ROOT'];
       $path .= "/includes/locations.txt";
       include_once($path);
    ?>

    I placed this code in a template file (where the page content would be) and used the template when I wanted to display the data inside the locations.txt file.

Topic Closed

This topic has been closed to new replies.

About this Topic