插件和主题使用此对象来创建他们的自定义帖子显示。 当插件使用易受攻击的类时,就会出现该漏洞。一个这样的插件是Elementor Custom Skin 。...comment] $this->query contains user-supplied data wp_reset_postdata();//this fixes some issues with some get_the_ID...== $query['field'] ) { $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); return
二、打开主题的single.php,找到下面这段代码: if(have_posts()): while(have_posts()):the_post(); 在其后面加上一句setPostViews(get_the_ID...());即是上面的代码变为: if (have_posts()) : while (have_posts()) : the_post();setPostViews(get_the_ID()); 三、在需要显示的地方添加以下代码调用...php echo number_format(getPostViews(get_the_ID())); ?>次 当然,“点击xx次”可以修改你想要得内容。
1.在文章编辑功能区->更多->选项 2.勾选自定义字段 3.在编辑区输入自定义字段 4.将输入的自定义字段添加到自定义栏目 完成上述操作后在文件中键入如下代码即可显示自定义栏目的值...> $post_id文章的ID(如果在循环中,你可以用 get_the_ID()来设置), $key自定义字段的名称(键值), $single是否以字符串形式返回,false会返回数组形式。...if (have_posts()) ://如果有文章 while (have_posts()) : the_post(); //开启主循环 $xzmeta = get_post_meta(get_the_ID...(),'xzmeta',true); endwhile; endif; get_the_ID()获取当前循环的文章ID
WordPress的自定义字段是个非常有用的功能,自定义域是对wp文章功能的扩展和补充,通过使用WP自定义字段功能,可以给文章增加些额外的内容,如用WP做淘客模板时给产品添加商品价格显示,添加购买链接等...WordPress自定义字段使用方法: 在使用WordPress撰写文章的时候,在内容输入框下面有一个“自定义栏目”(没有发现的童鞋,在后台顶部,点击“显示选项”——勾选“自定义栏目”) 点击“输入新栏目...> 参数详解 $post_id 文章的ID,如果在循环中,可以用 get_the_ID() 来设置 $key 自定义字段的名称(键值) single 是否以字符串形式返回,false会返回数组形式(如果没有设置这个自定义字段的话...php echo get_post_meta(get_the_ID(), link, true); ?>
the_title()函数用于显示或检索博客所有区域的页面标题 ,而the_permalink()函数则用于输出页面的永久链接 。...处理特殊情况:如果遇到复杂的页面结构或者需要考虑SEO优化等因素,可能还需要进一步处理,比如动态生成自定义的页面标题和链接,以适应不同的显示需求。 -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post__not_in' => array(get_the_ID
版本开始,添加了 分类法(taxonomy)参数,这就意味着,除了 标签(tags)以外,还可以将 分类(Categories) 或其他 自定义分类法(Custom Taxonomies)作为“云”显示...注: child_of 不是一个直接的 wp_tag_cloud 数组的键(Key),但由于这个函数使用 wp_parse_args() 和 get_terms() ,你可以通过 get_terms()...默认情况下的输出内容: smallest —— 最小的标签(使用次数最少)显示大小为8 largest ——最大的标签(使用次数最多)显示大小为22 unit —— 最大值最小值的单位为’pt’ number...—— 至多显示45个标签 format —— 以平面形式显示所有标签(标签之间用空格隔开) separator —— 显示标签之间的空格 orderby —— 按名称为标签排序 order —— 以升序排列..."; $html .= "{$tag- name} ({$tag- count})</a </li "; } $html .= '</ul '; echo $html; 如果要求随机获取标签在首页显示
、XML 格式: 如果想使用 xml 格式,只要使用张戈博客前几天写的《WordPress 免插件生成完整站点地图(sitemap.xml)的 php 代码》一文中的 php 代码即可,成功提交后如下显示...php /* 博客分类 */ $terms = get_terms('category', 'orderby=name&hide_empty=0' ); $count = count($terms);...php /* 标签(可选) */ $tags = get_terms("post_tag"); foreach ( $tags as $key => $tag ) { $link =
php /* 分类 */ $terms = get_terms('category', 'orderby=name&hide_empty=0' ); $count = count($terms); if...php /* 标签(可选) */ $tags = get_terms("post_tag"); foreach ( $tags as $key => $tag ) { $link = get_term_link...首先将自己所使用的的sitemap.xml插件都禁止,然后看看网站的根目录是否会生成一个sitemap.xml文件,如果已经有了,你可以试一下你的域名/sitemap.xml,如果可以显示网站地图信息,
wordpress基础上开发的,有些函数是通用的,有些需要自己调用,比如文章分类用category_description()就可以调用,而woocommerce的产品分类描述可能需要用下面的代码才能显示出来...php $args = array( 'taxonomy' => 'product_cat' ); $terms = get_terms
前言 本次教程是实现WordPress自动检查文章是否被百度收录,如果收录了就显示“已经收录”,如果没有收录就显示为“百度未收录”,会直接在百度站长平台提交当前页面的URL了,方便蜘蛛发现新文章,从而加快文章的收录速度...get_the_ID() : $post_id; $baidu_record = get_post_meta($post_id,'baidu_record',true); if( $baidu_record...>百度未收录'; } } 2、去编辑WordPress主题下的文章模板(一般是single.php),在想要显示收录结果的位置添加如下代码并保存。 <?
设置显示的模板 它还可以让你显示浏览次数最多的日志列表的模板 另外它还能详细设置哪些页面可以显示日志的浏览此数和显示给谁,我觉得这个貌似有点多余了。...WP-Postviews 使用 要让你的博客在页面上显示浏览次数,你需要修改你博客当前使用的主题,在主循环中插入以下代码: <?...显示最受欢迎的日志的代码是: <?...php $numberposts = 10; //要显示日志的数量 $most_viewd_posts = new WP_Query(); //使用 WP_Query 自定义 WordPress Loop...php echo get_post_meta(get_the_id(), 'thumbnail', true); ?>" alt="<?php the_title(); ?
> 3.将以下代码添加到要显示浏览次数的位置, 例如 文章列表(template-parts/content.php), 文章详情页面(template-parts/content-single.php...php echo ‘阅读数’.getPostViews(get_the_ID());?...未经允许不得转载:肥猫博客 » 详解WordPress文章阅读量如何统计和显示(非插件)
php /* 博客分类 */ $terms = get_terms('category', 'orderby=name&hide_empty=0' ); $count = count($terms);...php /* 标签(可选) */ $tags = get_terms("post_tag"); foreach ( $tags as $key => $tag ) { $link =...php /* 博客分类 */ $terms = get_terms('category', 'orderby=name&hide_empty=0' ); $count = count($terms);...php /* 标签(可选) */ $tags = get_terms("post_tag"); foreach ( $tags as $key => $tag ) { $link =...2 个 php 脚本查看效果了,比如: http://zhangge.net/sitemap_baidu_sp.php http://zhangge.net/sitemap_360_sp.php 若显示正常
user_ID > 0) { $email = get_userdata($user_ID)->user_email; //对博主直接显示内容...return $notice; } global $wpdb; $post_id = get_the_ID
_POST['_meta_info'] ); } } } add_action( 'save_post', 'save_post_options' ); 啰啰嗦嗦一大段代码,实际上只显示了一个单选框...wpjam_register_post_option('seo', [ 'title' => 'SEO设置', // 文章选项标题 'context' => 'side', // 显示在文章编辑页的侧边...」: add_filter('document_title', function($title){ if(is_single()){ // 文章详情页 return get_post_meta(get_the_ID...文章详情页 foreach(['description', 'keywords'] as $type){ // 文章SEO描述和关键字 if($meta_value = get_post_meta(get_the_ID
get_previous_post get_previous_posts_link previous_posts_link have_posts is_post(不赞成) is_single is_sticky get_the_ID...wp_get_post_terms wp_set_post_terms wp_count_terms has_term is_object_in_term 其他 add_meta_box remove_meta_box get_the_ID...get_taxonomies get_term get_the_term_list get_term_by the_terms get_the_terms get_term_children get_term_link get_terms
if ($user_ID > 0) { $email = get_userdata($user_ID)->user_email; //对博主直接显示内容...if (empty($email)) { return $notice; } global $wpdb; $post_id = get_the_ID
get_post_format() "status") { get_template_part( 'tpl/content', get_post_format() ); } 保证「状态」形式的文章不会显示在首页...在第11行增加 if (get_post_format() == "status") { continue; } 保证「状态」形式的文章不会显示在首页。...get_post_thumbnail_id(get_the_ID())) { ?> <?...2.进入「外观 – 主题设置 – 其它 – 首页不显示的分类文章」,输入刚刚得到的tag_id。 3.进入分类的详细设置,「图像描述」的内容即为副标题。
(发表评论请勾选 在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。...notice; } if (empty($email)) { return $notice; } global $wpdb; $post_id = get_the_ID...jQuery隐藏侧边栏 WordPress 中文分词搜索 WordPress 主题 图片自适应宽度 WordPress 优化404页面 WordPress 4.2.1 gravatar头像无法显示
如果能在网站显示出这些预定发布的文章,应该会吸引读者继续关注你的博客吧? 思路 把即将推出的文章显示在侧边栏是个好办法,不过很多主题都只能以小工具的形式在侧边栏添加内容。...get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?
领取专属 10元无门槛券
手把手带您无忧上云