是否显示描述show_rating是否显示评分show_updated是否显示更新时间sort_order排序方式text_before_link链接前文本text_after_link链接后文本text_after_all...所有链接后文本list_limit显示数量限制2....'show_description' => 1, // 是否显示描述 'show_images' => 1, // 是否显示图片 '...php// 按分类获取链接$categories = get_terms('link_category', array('hide_empty' => true));foreach ($categories...post_type' => 'partner'));while ($partners->have_posts()) : $partners->the_post(); $url = get_post_meta(get_the_ID
插件和主题使用此对象来创建他们的自定义帖子显示。 当插件使用易受攻击的类时,就会出现该漏洞。一个这样的插件是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
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
二、打开主题的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次”可以修改你想要得内容。
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); ?>
、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,如果可以显示网站地图信息,
在某篇文章或当前文章的适当位置显示所有评论者名称列表,或在文章列表摘要下方显示评论者头像,可以引导读者也发个热情洋溢的评论。 1....显示评论者名称 1.1 效果 独元殇, 耳朵的主人, 雅岚, Kevin’s, 小彦, 阿和, Mr.Chou等人对本文发表了17条热情洋溢的评论。...$id : get_the_ID(); if ( $post_id ) { $comments = get_comments( array( 'post_id' =>...显示头像(加强版) 其实在折腾上面名称时特别想弄一个头像版(替代文字名称)。 2.1 代码 php get_the_ID()); if ( !
wordpress基础上开发的,有些函数是通用的,有些需要自己调用,比如文章分类用category_description()就可以调用,而woocommerce的产品分类描述可能需要用下面的代码才能显示出来...php $args = array( 'taxonomy' => 'product_cat' ); $terms = get_terms
wp_get_current_user()->ID;if ( $user_ID > 0) {$email = get_userdata( $user_ID )->user_email;//对博主直接显示内容...COOKIEHASH]);} else {return $notice ;}if ( empty ( $email )) {return $notice ;}global $wpdb ;$post_id = get_the_ID...int) wp_get_current_user()->ID;if ($user_ID > 0) {$email = get_userdata($user_ID)->user_email;//对博主直接显示内容...int)wp_get_current_user()->ID;if ($user_ID > 0) {$email = get_userdata($user_ID)->user_email;//对博主直接显示内容...COOKIEHASH]);} else {return $notice;}if (empty($email)) {return $notice;}global $wpdb;$post_id = get_the_ID
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 若显示正常
前言 本次教程是实现WordPress自动检查文章是否被百度收录,如果收录了就显示“已经收录”,如果没有收录就显示为“百度未收录”,会直接在百度站长平台提交当前页面的URL了,方便蜘蛛发现新文章,从而加快文章的收录速度...get_the_ID() : $post_id; $baidu_record = get_post_meta($post_id,'baidu_record',true); if( $baidu_record...>百度未收录'; } } 2、去编辑WordPress主题下的文章模板(一般是single.php),在想要显示收录结果的位置添加如下代码并保存。 <?
> 3.将以下代码添加到要显示浏览次数的位置, 例如 文章列表(template-parts/content.php), 文章详情页面(template-parts/content-single.php...php echo ‘阅读数’.getPostViews(get_the_ID());?...未经允许不得转载:肥猫博客 » 详解WordPress文章阅读量如何统计和显示(非插件)
user_ID > 0) { $email = get_userdata($user_ID)->user_email; //对博主直接显示内容...return $notice; } global $wpdb; $post_id = get_the_ID
设置显示的模板 它还可以让你显示浏览次数最多的日志列表的模板 另外它还能详细设置哪些页面可以显示日志的浏览此数和显示给谁,我觉得这个貌似有点多余了。...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(); ?
_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
php echo get_post_meta(get_the_ID(), 'post_views', true); ?> 显示文章浏览量...} set_post_views($post_id);}add_action('wp_head', 'track_post_views');使用时,将第一个代码块中的查询部分放在你想要显示热门文章的模板位置
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())) { ?> 显示的分类文章」,输入刚刚得到的tag_id。 3.进入分类的详细设置,「图像描述」的内容即为副标题。
如果查看次数超过限制,则显示一条消息告知用户已超过查看次数限制。...as needed if (is_user_logged_in()) { $user_id = get_current_user_id(); $post_id = get_the_ID