版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wzl505/article/details/81586912
1、wordpress自定义值的运用:
在页面新建一个自定义值。名称自定义,内容填写你需要插入到特定页面的代码。
在外观——>编辑——>header.php中加入如下代码,代码加在<?php wp_head(); ?>后面。
<!--自定义值-->
<?php if (is_single() || is_page()) {
$more = get_post_meta($post->ID, 'more', true);
if (!empty($more)) { ?>
<?php echo $more; ?>
<?php } } ?>
2、鼠标经过显示隐藏的代码。<?php echo get_template_directory_uri(); ?>//主题路径
<style>
.is-hidden{display:none;}
.is-visible{display:block;}
</style>
<script src="<?php echo get_template_directory_uri(); ?>/assets/js/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
if($(".header-block").css('display') == "block"){
$(".header-block").addClass("is-hidden");
}
$("#menu-item-145").each(function(index, element) {
$("#menu-item-145").on("mouseover",function(){
if($(".header-block").hasClass("is-hidden")){
$(".header-block").removeClass("is-hidden").addClass("is-visible");
}else{
$(".header-block").removeClass("is-visible").addClass("is-hidden");
}
});
});
});
</script>
3、点击显示隐藏
<script>
$(document).ready(function(){
$(".button.primary").click(function(){
if($(".col.small-12.large-12").hasClass("hidden")){
$(".col.small-12.large-12").removeClass("hidden");
}else{
$(".col.small-12.large-12").addClass("hidden");
}
});
});
</script>