小工具      在线工具  汉语词典  dos游戏  css  js  c++  java

wordpress相册查件_您可以使用WordPress中的便利贴做的6件事

python,java,css,wordpress,html 额外说明

收录于:15天前

wordpress相册检查

Did you know that WordPress allows you to feature your posts by 使用置顶帖 feature. However, sticky posts are one of the least known features of WordPress. In this article, we will show you 6 cool things you can do with sticky posts in WordPress.

您是否知道WordPress允许您使用置顶帖功能来展示您的帖子。 但是,粘性帖子是WordPress鲜为人知的功能之一。 在本文中,我们将向您展示WordPress中的粘帖可以做的6件事。

Sticky Post Tricks
影片教学 Video Tutorial

演示地址

如果您不喜欢该视频或需要更多说明,请继续阅读。

如果您不喜欢该视频或需要更多说明,请继续阅读。

1.自动过期即时贴 1. Automatically Expire Sticky Posts

如果您使用置顶帖子来突出显示特殊活动或优惠券,那么您需要在该活动结束后取消置顶帖子。

如果您使用置顶帖来突出显示特殊活动或优惠券,则需要在活动结束后取消置顶贴。

这听起来像是不必要的工作,您应该将其自动化。

这听起来像是不必要的工作,您应该将其自动化。

Simply install and activate the 使置顶帖子过期 plugin. Upon activation, you can set expiry date for sticky posts.

只需安装并激活使置顶帖子过期插件即可。 激活后,您可以为即时贴设置过期日期。

Setting expiration date for sticky post

After the expiry date, your sticky post will automatically become a normal post. For detailed instructions take a look at our tutorial (with video) on how to set 置顶帖的过期日期 in WordPress.

有效期过后,您的粘性帖子将自动变为普通帖子。 有关详细说明,请看一下我们的教程(带视频),该教程如何设置WordPress中置顶帖子过期日期

2.类别的便利贴 2. Sticky Posts for Categories

默认情况下,置顶帖子仅出现在您网站的首页上。但是,如果您想在类别存档页面上显示特色内容怎么办?

默认情况下,置顶帖子仅出现在网站的主页上。但是,如果您想在类别存档页面上显示特色内容怎么办?

You can do that by installing and activating the 类别置顶帖 plugin. Upon activation, edit a post that you want to feature and select the sticky post category.

您可以通过安装并激活类别置顶帖插件来做到这一点。 激活后,编辑要突出显示的帖子,然后选择即时贴类别。

Adding a sticky post to specific category

For more detailed instructions, see our tutorial on how to add 类别置顶帖 in WordPress.

有关更多详细说明,请参阅有关如何在WordPress中对于类别添加置顶帖教程。

3.显示最新的即时贴 3. Display Latest Sticky Posts

通常,粘性帖子用于特色帖子,以显示您最突出的内容。但过了一段时间,您的旧精选帖子就会消失在档案中。您可以通过在自定义存档页面或网站上的其他任何位置显示旧的特色内容,使它们恢复生机。

通常,粘性帖子用于特色帖子以显示您最突出的内容。但过了一段时间,你的旧精选帖子就从档案中消失了。您可以将旧的特色内容显示在自定义存档页面或网站上的任何其他位置,从而使其恢复生机。

Simply paste this code in your theme’s 函数.php file or a 特定于站点的 WordPress 插件.

只需将此代码粘贴到主题的函数.php文件或具体的在网站的 WordPress 插件中


function wpb_latest_sticky() { 

/* Get all sticky posts */
$sticky = get_option( 'sticky_posts' );

/* Sort the stickies with the newest ones at the top */
rsort( $sticky );

/* Get the 5 newest stickies (change 5 for a different number) */
$sticky = array_slice( $sticky, 0, 5 );

/* Query sticky posts */
$the_query = new WP_Query( array( 'post__in' => $sticky, 'ignore_sticky_posts' => 1 ) );
// The Loop
if ( $the_query->have_posts() ) {
	$return .= '<ul>';
	while ( $the_query->have_posts() ) {
		$the_query->the_post();
		$return .= '<li><a href="' .get_permalink(). '" title="'  . get_the_title() . '">' . get_the_title() . '</a><br />' . get_the_excerpt(). '</li>';
		
	}
	$return .= '</ul>';
	
} else {
	// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();

return $return; 

} 
add_shortcode('latest_stickies', 'wpb_latest_sticky');

After adding this code, simply create add the shortcode [latest_stickies] wherever you want to display your latest sticky posts.

添加此代码后,只需在要显示最新即时贴的位置创建简码[latest_stickies]

For detailed instructions, visit our article: 如何在 WordPress 中显示最新的置顶帖子.

有关详细说明,请访问我们的文章: 如何在WordPress中显示最新的便笺

4.自定义帖子类型的粘性帖子 4. Sticky Posts for Custom Post Types

Sticky post feature is only available for WordPress posts, but this does not mean that you cannot add this feature for other 帖子类型.

粘性帖子功能仅适用于WordPress帖子,但这并不意味着您不能为其他岗位类型添加此功能。

Simply install and activate the 粘性自定义帖子类型 plugin. Once you have activated the plugin, visit 设置 » 阅读 and enable sticky posts for any post type you want.

只需安装并激活粘性自定义帖子类型插件即可。 激活插件后,请访问“设置”»“阅读”,并为所需的任何帖子类型启用即时贴。

Sticky Post on a custom post type

For more detailed instructions check out our tutorial on how to add WordPress 自定义帖子类型中的粘性帖子.


有关更详细的说明,请查看我们的教程,了解如何在 WordPress 自定义帖子类型中添加置顶帖

5.如何从WordPress Loop中隐藏即时贴 5. How to Hide Sticky Posts From WordPress Loop

使用置顶帖子时,您会注意到默认情况下 WordPress 将置顶帖子显示在所有 WordPress 帖子的顶部。例如,如果您有一个循环来显示最近的帖子,那么无论何时添加置顶帖子,它们都会显示在顶部。

使用置顶帖子时,您会注意到 WordPress 默认将您的置顶帖子显示在所有 WordPress 帖子的顶部。例如,如果您有一个显示最近帖子的循环,则每当您添加卡片时,它都会显示在顶部。

To avoid this simply use ignore_sticky_posts argument in your WordPress query, like this:

为了避免这种情况,只需在WordPress查询中使用ignore_sticky_posts参数,如下所示:


<?php
$args = array(
	'posts_per_page' => 10,
	'ignore_sticky_posts' => 1
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
?>

See our tutorial on how to 从 WordPress 循环中排除置顶帖子 for more detailed instructions.

请参阅我们的教程,了解如何从 WordPress 循环中排除置顶帖子,以获取更多详细说明。

6.设置粘性帖子的样式 6. Styling Sticky Posts

想要为您的置顶帖子添加自定义样式吗?

想要为您的便签添加自定义样式吗?

Many WordPress themes use post_class() function to automatically add post classes for each post. If your theme is already using post_class() function, then you will see sticky class added to your sticky posts.

许多WordPress主题使用post_class()函数自动为每个帖子添加帖子类别。 如果您的主题已经在使用post_class()函数,那么您会看到粘性类已添加到您的粘性帖子中。

Sticky class added to post container

如果您的主题没有向帖子容器 div 添加粘性类,那么您可以通过将 post_class() 函数添加到帖子 div 或文章容器中来自行添加。

如果您的主题未将粘性类添加到帖子容器 div,您可以通过将 post_class() 函数添加到帖子 div 或文章容器来自行添加粘性类。


<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

Now you can use the .sticky CSS class in your 儿童主题‘s stylesheet. Here is some basic CSS to get you started:

现在您可以使用了。 副主题的样式表中的sticky CSS类。 以下是一些基本CSS入门指南:


.sticky { 
background-color:#ededed;
border:1 px solid #f5f5f5;
color:#272727;
padding:5px;
}

.sticky:before {
  content: "Featured";
  color: #FFF;
  background: #f20000;
  padding: 10px;
  display: inline-block;
  text-align: right;
  float: right;
  font-weight: bold;
  text-transform: uppercase;
}

这就是我们使用“二十一十二”主题的演示网站上的外观。

这就是我们使用“十二十二”主题的演示网站上的样子。

Styling a sticky post in WordPress

That’s all, we hope this article helped you learn some cool things to do with sticky posts on your WordPress site. You may also want to check out our guide on 10 most wanted WordPress 的类别黑客和插件.

仅此而已,我们希望本文能帮助您学习一些有趣的事情,这些事情与WordPress网站上的粘帖有关。 您可能还需要查看关于 WordPress 10种最需要黑客和插件的类别指南。

If you liked this article, then please subscribe to our YouTube 频道 for WordPress video tutorials. You can also find us on 推特 and 谷歌+.

如果您喜欢这篇文章,请订阅我们的YouTube 频道 WordPress视频教程。 您也可以在推特谷歌+上找到我们。

翻译自: https://www.wpbeginner.com/beginners-guide/6-cool-things-you-can-do-with-sticky-posts-in-wordpress/

wordpress相册检查

. . .

相关推荐

额外说明

Creo软件安装包分享(附安装教程)

目录 一、软件简介 二、软件下载   一、软件简介 Creo是一款机械设计软件,全称为Creo Parametric,是PTC公司推出的一款三维CAD/CAM/CAE软件。Creo被广泛应用于机械设计、汽车、航空、航天、电子、家电、玩具等各个行业,是世界

额外说明

【Python入门教程】第81章 常用字符串方法分割字符串

本篇将会介绍如何利用字符串对象的 split() 方法将一个字符串拆分成多个子串。 字符串 split() 方法 字符串的 split() 方法用于拆分字符串,返回一个由子串组成的列表。split() 方法的语法如下: str.split(sep=Non

额外说明

Weblogic的了解、安装及其使用

Weblogic理解 1.Weblogic介绍 1.1 简介 1.2 Weblogic特性 1.3 为什么要选择Oracle WebLogic Server? 1.4 扩展 weblogic术语 1.5、和其他服务器区别 1.5.1 tomcat (免费

额外说明

uniapp实战——创建项目和清理结构及配置基本外观

QQ 1274510382 Wechat JNZ_aming 商业联盟 QQ群538250800 技术搞事 QQ群599020441 解决方案 QQ群152889761 加入我们 QQ群649347320 共享学习 QQ群674240731 纪年科技am

额外说明

VC++调用HtmlHelp打开chm帮助文档(附源码)

VC++常用功能开发汇总(专栏文章列表,欢迎订阅,持续更新...)https://blog.csdn.net/chenlycly/article/details/124272585C++软件异常排查从入门到精通系列教程(专栏文章列表,欢迎订阅,持续更新.

额外说明

手写Mybatis SQL注解

手写Mybatis SQL注解 一、效果演示 数据库中有user表 Mapper 3.使用Mapper,添加数据 查询 一、实现 1. 思路 先模仿mybatis自定义自己的注解,并封装下数据库连接和SQL操作的工具类。由于Mapper一般都是接口形式,

额外说明

【Java 基础篇】Java 面向对象详解:面向对象编程的艺术

如果你正在学习Java编程,面向对象编程(Object-Oriented Programming,OOP)是一个不可或缺的概念。Java是一种面向对象的编程语言,这意味着它的编程范式基于对象、类和继承。在本篇博客中,我们将深入探讨Java中面向对象编程的

额外说明

如何采用SQL Server身份验证登录

文章目录 一、用Windows身份验证模式登录服务器 二、修改服务器身份验证模式 (一)打开服务器属性对话框 (二)修改服务器身份验证 (三)修改sa登录属性 (四)将登录名sa状态改为启用 三、重启SQL Server服务 四、采用SQL Server

额外说明

VB讲课笔记11:多重窗体与环境应用

VB讲课笔记11:多重窗体与环境应用 主要考查多重窗体的应用以及VB工程结构。以选择题和操作题两种形式考核。选择题中所占分值较少,约占总分的1%,多属于概念题。操作题中,主要出现在简单应用题,操作题试题的抽中概率约为4%。 一、多重窗体应用程序 一个VB

额外说明

【FinalShell】win10 / win 11:远程连接 Linux 工具 FinalShell 下载、安装

目录 一、前言 二、FinalShell 下载 (1)Windows 版下载(示例) (2)macOS 版下载 (3)Linux 版下载 三、FinalShell 安装 一、前言 xshell 和 xftp 是较为常用,Windows 远程连接 Linu

ads via 小工具