multisite - Switch_to_blog() outside wordpress

how can I load switch_to_blog() function outside wordpress?$blog_id = '7';require_once( $_SERVER['DOCUME

how can I load switch_to_blog() function outside wordpress?

$blog_id = '7';
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
switch_to_blog($blog_id);
echo get_option('blogname');
restore_current_blog();
echo 'You switched back.';

I get error:

Fatal error: Call to a member function set_prefix() on a non-object in /home/public_html/wp-includes/ms-settings.php on line 126

Any ideas ?

UPDATE It can be loaded but without any function just this code ? What global variables is missing ?

how can I load switch_to_blog() function outside wordpress?

$blog_id = '7';
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
switch_to_blog($blog_id);
echo get_option('blogname');
restore_current_blog();
echo 'You switched back.';

I get error:

Fatal error: Call to a member function set_prefix() on a non-object in /home/public_html/wp-includes/ms-settings.php on line 126

Any ideas ?

UPDATE It can be loaded but without any function just this code ? What global variables is missing ?

Share Improve this question edited Nov 7, 2014 at 9:59 andys asked Nov 6, 2014 at 20:48 andysandys 3161 gold badge3 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This may not be possible.

From the Codex page Integrating WordPress with your Website, which explains how to use WordPress "outside" of WordPress:

These directions will not work on a MultiSite Network.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744926644a4601476.html

相关推荐

  • multisite - Switch_to_blog() outside wordpress

    how can I load switch_to_blog() function outside wordpress?$blog_id = '7';require_once( $_SERVER['DOCUME

    1天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信