SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    SitePoint Member
    Join Date
    May 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to show footer from another wordpress site ?

    Hello,
    Is it possible to show same footer between 2 wordpress site and i am using same theme and same database with different prefix.
    Such as :- my 2 sites is
    http://www.mysite.com
    http://www.mysite.com/blog

    I am using same theme in both site. Now is it possible to show 1st site's footer to second site's footer ?

    Thanks in advance !

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,117
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    If they both have the same domain name, they are not different sites. So yes, you definitely can have the same footer on each. Ideally, you should have the same design on each (in my view, anyhow). The best way to do this is with something like PHP, where you have the footer stores in one place that is pulled into each page with a simple link. E.g. you can use PHP includes for this.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    SitePoint Member
    Join Date
    May 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    If they both have the same domain name, they are not different sites. So yes, you definitely can have the same footer on each. Ideally, you should have the same design on each (in my view, anyhow). The best way to do this is with something like PHP, where you have the footer stores in one place that is pulled into each page with a simple link. E.g. you can use PHP includes for this.
    Hi ralph,
    Thanks for your quick reply.
    Thanks for nice link.
    i am a nob, i am not well in coding. would you please specifically tell me the process.

    Is the process is :-
    i should copy my footer.php file in my second site ( or folder). But footer is same, because i use same theme.

    Regards

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,117
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    We'd probably need more information to understand your setup properly. Do you have a link to your site? If you have your footer code for your site in a PHP include, you should be able to pull it in to your footer template in WordPress.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  5. #5
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,791
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    it seem to me it's the same site that you are talking about, but different pages with that site. correct? if so WP has a function specifically for this:
    <?php get_footer( $name ); ?>, where $name = the file name of the PHP template you want to include as a footer.

    Other than that, and as long as the footer code you want o use resides in the same server, you can just do a plain PHP include and direct it to that file <? include '../Path/To/Footer/File.php'; ?>

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,117
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by dresden_phoenix View Post
    it seem to me it's the same site that you are talking about, but different pages with that site.
    It looks like the only WP part of the site is the /blog/ section, which makes it a tad trickier, as the template has to be matched first (if that is even desired).
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  7. #7
    SitePoint Member
    Join Date
    May 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dresden_phoenix View Post
    it seem to me it's the same site that you are talking about, but different pages with that site. correct? if so WP has a function specifically for this:
    <?php get_footer( $name ); ?>, where $name = the file name of the PHP template you want to include as a footer.

    Other than that, and as long as the footer code you want o use resides in the same server, you can just do a plain PHP include and direct it to that file <? include '../Path/To/Footer/File.php'; ?>

    Hello, thanks for reply. Also thank you ralph for reply.

    For clarify :-
    I have installed wordpress in my main site such as:- www.yyyyyyyyyyy.com
    and then i have installed shop using wordpress in a folder of main domain. So my shop domain is www.yyyyyyyyyyy.com/shop
    and i have used same theme in both.
    Now i wanna the same footer widgets in my first site to my shop site footer widget. Yes, i can manually do this by creating some links ( such as recent post links of main site etc.) . But whenever i will add anything or update my main site's footer widgets then it will not automatically update in my shop site.
    And this is the point. i just wanna do this. Means pull update of main site's footer to my shop site automatically.
    Now is it possible ? if possible then how ? Please help me.

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,117
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by kiddie View Post
    I have installed wordpress in my main site
    Oh, OK, so it's a full WP site. That's probably better. Presumably the shop plugin has some instructions for utilizing the same theme elements. Which shop add-on are you using?

    Off Topic:

    I've moved this to the CMS forum, as this is really a WordPress issue rather than CSS.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  9. #9
    SitePoint Enthusiast OMGCarlos's Avatar
    Join Date
    Apr 2012
    Location
    Boston, MA
    Posts
    91
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The problem is that they are on different Wordpress installs, so when you grab the footer from Site A all the database data will be pulled from Site B. A workaround could be:

    Include the file in SiteB with a querystring, something like:
    include('../path/to/footer/A/footer.php?location=SiteB');

    At the very top of SiteA's footer.php:
    Code:
    if(array_key_exists['location', $_GET]){
        if($_GET['location'] == 'SiteB'){
            ...Connect to SiteA's database...
        }
    }
    At the very bottom of SiteA's footer.php:

    Code:
    if(array_key_exists['location', $_GET]){
        if($_GET['location'] == 'SiteB'){
            ...Connect back to SiteB's database...
        }
    }
    I have no idea if this would work, but in theory it should.

  10. #10
    SitePoint Zealot bronze trophy
    Join Date
    Jan 2012
    Posts
    116
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If the footer exists as it's own piece of content, then you can grab the link to the URL of the footer, and do a file_get_contents.

    Code:
    $url_to_footer = "http://www.[path to your footer]";
    
    $footer = file_get_contents($url_to_footer);
    
    echo $footer;

  11. #11
    SitePoint Member
    Join Date
    May 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @ Carlos, thanks for reply.
    Will you please explain this, where can i put that ?



    Quote Originally Posted by CMS Dude View Post
    If the footer exists as it's own piece of content, then you can grab the link to the URL of the footer, and do a file_get_contents.

    Code:
    $url_to_footer = "http://www.[path to your footer]";
    
    $footer = file_get_contents($url_to_footer);
    
    echo $footer;
    Thanks for your tips. But will you please tell me where can ad this code ?

    If there any matter of iframe ? Can i do that by iframe ? May be iframe is so easy for me to easily do this.

  12. #12
    SitePoint Zealot bronze trophy
    Join Date
    Jan 2012
    Posts
    116
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kiddie View Post
    Will you please explain this, where can i put that ?
    Definitely no to the iframes thing.

    Ideally you would put that code in a dedicated footer template file (footer.php or similar).

    Wherever it is that you're outputting your footer. If you're not using includes and all of your template code is just being lumped together, then it would likely be placed in your index.php file wherever your footer is designated. If you don't know where that is, then you have bigger issues , and need to get reading and learning the file and templating structure of Wordpress (and possibly html in general). Otherwise, none of these suggestions we're making are going to help you or make sense to you.

  13. #13
    SitePoint Enthusiast OMGCarlos's Avatar
    Join Date
    Apr 2012
    Location
    Boston, MA
    Posts
    91
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Generally, that would work. But...

    Let's say his footer has a variable that get's pulled from the database like "bloginfo". If you include the other footer in the normal way (file_get_contents, include, require, etc) then all the database dependent variables will get loaded from the current site, and not external one...which is what I think he's trying to do (external being same domain, different install).

    That's why you would need to change the database being used FIRST, load the footer using "include" etc, then switch the database back to the original.

    Unless I'm completely missing what he's trying to do lol

  14. #14
    SitePoint Zealot bronze trophy
    Join Date
    Jan 2012
    Posts
    116
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by OMGCarlos View Post
    Generally, that would work. But...

    Let's say his footer has a variable that get's pulled from the database like "bloginfo". If you include the other footer in the normal way (file_get_contents, include, require, etc) then all the database dependent variables will get loaded from the current site, and not external one...
    File_get_contents yanks the final, rendered HTML, so no issues there.

  15. #15
    SitePoint Member
    Join Date
    May 2012
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks to both of you .
    But i haven't understood yett. But if you give me clear suggestion ( i mean normally ) that it will be very helpful for me. Because my username is kiddie and i am really a kid in coding.
    One of my friend suggest me to use iframe to solve that. But i don't think, how can i pull a part of website by iframe. my footer url is /wp-content/theme/themename/footer.php .
    but how can pull this.
    Any suggestion ?

  16. #16
    SitePoint Zealot bronze trophy
    Join Date
    Jan 2012
    Posts
    116
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kiddie View Post
    One of my friend suggest me to use iframe to solve that. But i don't think, how can i pull a part of website by iframe. my footer url is /wp-content/theme/themename/footer.php .
    but how can pull this.
    Any suggestion ?
    Iframes aren't very cross-browser compatible, and it will be an ugly solution. Just don't even bother with it.

    What I'm suggesting is that the footer area exists as a content type in Wordpress. Make it it's own "post" or page or what have you. Then it will have an actual URL assigned to it; it would exists on the web like it's own little post. Albeit a post that just consists of .... an ugly footer, sitting there by it's lonesome.

    Once you have your footer as it's own wordpress post ... you then go to the template file where your footer is output (and I'm sorry I can't tell you where that is -- you're just going to have to learn wordpress and it's structure ). Once you find where your footer is within your template file, replace it with the code I posted above, using the url to your footer as the parameter.

    It's really simpler than it sounds.

  17. #17
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,791
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    Assuming we are talking about two distinct installs ( As carlos said) ... you have two DBs. Worpress or any other CMS does is to build a site from the data in the DB and the structure/design is essentially secondary. What you seem to be after is exactly the opposite of what WP is built to do; you want two separate sites to share ONE information (DB). This is why carlos was saying that the simplest thing to achieve this is to add a few extra line of code to the template of ONE of the two sites, making a connection to the DB of the other, just before you call the footer function.

    something like : $wpdb->get_results( "SELECT id, name FROM mytable" );

    if all you want is the footer to look/be structured the same way then really you are over complicating this and its just easier to COPY footer.php file into your other install. ( baring that, including it from it's other directory is the next least complicated move)

    Iframes would also work, but would be HORRIBLE TO STYLE.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •