Support » Networking WordPress » using a php file include in multiple multisite sites

  • Resolved lisagetcwscom

    (@lisagetcwscom)


    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    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.

    Thread Starter lisagetcwscom

    (@lisagetcwscom)

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

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    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.

    Thread Starter lisagetcwscom

    (@lisagetcwscom)

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘using a php file include in multiple multisite sites’ is closed to new replies.