(Wordpress Multisite)在选定的工作日中将页面显示为主页 [英] (Wordpress Multisite) Display page as homepage in chosen weekdays
问题描述
我如何根据一周的星期将所选页面显示为多站点网站的主页?我有这个函数来显示我的页面,取决于用户是否登录,接下来我希望它在星期二以不同的方式工作(选择不同的页面如下):
<$ p $如果(is_main_site()){
//只为主站点做东西
if(is_user_logged_in()){
$ page = 4284; //用于登录用户
update_option('page_on_front',$ page);
update_option('show_on_front','page');
} else {
$ page = 4133; //注销用户
update_option('page_on_front',$ page);
update_option('show_on_front','page');
您可以这样做:
$ today = date('l');
if($ today =='Tuesday'){
// your update_option()go here
}
How can I make chosen page to display as homepage of my multisite site depending on a week day? I have this function to display my page depending if user is logged in or not, next I want it to work differently during tuesday (picking different pages as follows):
function switch_homepage() {
if ( is_main_site() ) {
// Do stuff only for the main site
if ( is_user_logged_in() ) {
$page = 4284; // for logged in users
update_option( 'page_on_front', $page );
update_option( 'show_on_front', 'page' );
} else {
$page = 4133; // for logged out users
update_option( 'page_on_front', $page );
update_option( 'show_on_front', 'page' );
}
}
}
You can do something like this:
$today = date('l');
if ($today == 'Tuesday') {
// your update_option() goes here
}
这篇关于(Wordpress Multisite)在选定的工作日中将页面显示为主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!