Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Wordpress: Use a sidebar (widget) from different blog?

    Is it possible to call in a widget from a different blog installed on the same URL?

    This is what I put in for the code of the widget where I want it to be called into:

    PHP Code:
    <?php require ('http://www.imperial-mag.com/blog/wp-content/themes/Imperial_NEW/widgets/recent'); ?>
    It comes up with an error message as you can see here: http://www.imperial-mag.com/wordpress/

    Any help is appreciated.

    thanks in advance.

  • #2
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Using relative urls, should be something like this

    PHP Code:
    <?php require('/home/content/i/m/p/imperialmag/html/wordpress/wp-content/themes/Imperial_NEW/widgets/recent.php'); ?>

  • #3
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    I think the URL you are calling does not exist. I have checked and I am not able to access it.

  • #4
    New Coder
    Join Date
    Aug 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey that worked!

    One problem though. It's not pulling in the posts from the "blog" section.

    The posts are here: http://www.imperial-mag.com/blog/

    You can see here: http://www.imperial-mag.com/wordpress that the posts from the blog page are not being pulled in.

  • #5
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    If you have two different blogs running, you'll need to make sure the code you're including knows which database to access, otherwise it will simply access the database of the blog doing the including, instead of the blog it started in.

    Make sense?

    There are a few ways to do this, the way I would probably do it is to change the widget to output some html and file_get_contents that.

    So for example
    PHP Code:
    // blog's news-widget.php
    //   pull some info from the database
    //   output html directly

    //  main site
    //    file_get_contents('http://www.yoursite.com/wp-content/themes/whatever/widgets/news-widget.php'); 
    Not very hard, you just need to approach it slightly differently than you are now

  • #6
    New Coder
    Join Date
    Aug 2009
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mr e View Post
    If you have two different blogs running, you'll need to make sure the code you're including knows which database to access, otherwise it will simply access the database of the blog doing the including, instead of the blog it started in.

    Make sense?

    There are a few ways to do this, the way I would probably do it is to change the widget to output some html and file_get_contents that.

    So for example
    PHP Code:
    // blog's news-widget.php
    //   pull some info from the database
    //   output html directly

    //  main site
    //    file_get_contents('http://www.yoursite.com/wp-content/themes/whatever/widgets/news-widget.php'); 
    Not very hard, you just need to approach it slightly differently than you are now
    I am sorry - totally lost on this.

    I am at a beginner level on PHP.

    Can you explain further? Thanks.

  • #7
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    This might be a better direction for you to go if you're new to PHP

    http://wphacks.com/how-to-adding-an-...ordpress-blog/


  •  

    Posting Permissions

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