WordPress改变我主页的外观以适应季节

大家好,我联系了一个当地的度假胜地,目前正在更名,包括夏季和冬季活动。他们的设计师问,如果你点击主页上的按钮,是否有办法改变网站的外观以反映夏季活动/夏季外观。基本上,他们想要一个太阳图标或类似的东西,这样人们可以点击它,整个网站将改变,以反映夏季产品,并将反映更多的夏季色彩和照片等,这是可能的吗?当然可以。您必须修改一些主题的模板,以放入代码来检查季节并加载可选的CSS文件,或者添加一个body类,使您可以将季节作为CSS描述符的一部分使用。再考虑一下,我认为body类可能是最容易实现的,因为它可以在函数.php主题文件。 请参阅https://developer.wordpress.org/reference/hooks/bodyu class/若要了解如何在CSS中设置body类, ,可以执行类似于 .spring body{ background:lightgreen的操作; } 如果要更改网站上的实际内容,然后,您需要超越设置类的范畴,考虑使用按季节划分内容的自定义字段。 嘿: 这家伙的想法很有限: https://css-tricks.com/snippets/php/change-graphics-based-on-season/ 但更好的还在堆栈溢出: https://stackoverflow.com/questions/4241917/change-stylesheet-based-on-month-season-in-jquery 这个只使用jQuery添加类,但这可以通过WordPress实现: https://developer.wordpress.org/reference/functions/bodyu class/ 嘿: 你会想把你的页面提取下来,以便尝试一些东西出去。这个是2020主题的封面模板页: Expand I placed my 2020 theme style sheet in style.css, and imported it in the above with the following: Then I created the following seasonal.css file and imported it with the following: This is a start for a seasonal.css.This CSS content would be placed in the Custom CSS for you theme. /*Seasonal colorsbody class need to have season applied.*/body.winter { background-color: white; }body.spring { background-color: #ffffe6; /* yellowish */ }body.summer { background-color: #ccffcc; /* greenish */ }body.fall{ background-color: #fff2e6; /* orangish */ }body.winter > #site-footer {background-image: url(\"https://www.w3schools.com/w3css/img_snowtops.jpg\");background-position: 0 -100px;opacity: 0.8;background-color: lightgray;}body.winter > div.header-footer-group { background-color: gray; }body.spring > #site-footer {background-image: url(\"https://images2.minutemediacdn.com/image/upload/c_crop,h_1196,w_2121,x_0,y_218/f_auto,q_auto,w_1100/v1554930708/shape/mentalfloss/55573-istock-891978706.jpg\");background-position: 0 -200px;opacity: 1;background-color: #ffff99;}body.spring > div.header-footer-group { background-color: #ffff99; }body.summer > #site-footer {background-image: url(\"https://www.zastavki.com/pictures/originals/2014/Nature___Seasons___Summer_Waiting_for_the_summer_rain_078345_.jpg\");background-position: 0 -600px;opacity: 0.8;background-color: #99ff99;}body.summer > div.header-footer-group { background-color: #99ff99; }body.fall> .cover-color-overlay,body.fall> #site-footer {background-image: url(\"https://wallpapertag.com/wallpaper/full/d/d/0/845916-popular-seasonal-desktop-backgrounds-2560x1440-for-iphone.jpg\");background-position: 0 -200px;opacity: 1;background-color: orange;}body.fall> div.header-footer-group { background-color: orangered; }/**/我的2020儿童主题的粒子副本函数.php文件: <;?php/***2020个子函数和定义*/add_action(\"wp_enqueue_scripts\",\"my_theme_enqueue_styles\");function my_theme_enqueue_styles(){wp_enqueue_style(\"parent style\",get_template_directory_uri()\"/样式表\" );}/***========================================================================================**发件人:https://css-tricks.com/snippets/php/change-graphics-based-on-season/****返回字符串值:**春、夏、秋或冬**示例(例如页眉)用法:**bodyu class(getu season())*/function getu season(){/***今天的日期是什么=日期(\"z\",=\"春天\";elseif(=\"秋天\";else>扩展 我复制了最初的2020主题标题.php并对<;body>;标记做了如下小更改: <;?php/***WordPress 2020默认主题的头文件。**@链接https://developer.wordpress.org/themes/basics/template files/#模板-partials**@包WordPress*@子包Twentyu Twenty*@自Twenty Twenty 1.0*/?>;<;!DOCTYPE html>;<;html>Expand 因此body语句现在呈现如下(秋天在中间): <;body> 感谢所有帮助。他们决定暂缓。我将探讨每个人在决定自己想做什么时提出的选择。

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1159

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1060

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this-&gt;id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:800

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this-&gt;id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:888

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:925

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:873

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:855

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:825

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1695

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1298