WordPress Post - 密码保护&摘抄

发布于 2024-11-02 16:24:26 字数 85 浏览 0 评论 0原文

是 wordpress 的新手..我已经安装了它的版本 3.1.1..

我只是想知道如何使帖子受密码保护 以及如何添加它的摘录......?

am newbie in wordpress.. I have installed its version 3.1.1..

I just want to know how can I make the post password protected
and how to add excerpt for it....?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神也荒唐 2024-11-09 16:24:26

假设您指的是 WordPress 3.1.1,那么答案是在您撰写帖子的页面上有一个可以输入摘录的位置。您可以在此处的 WordPress Codex 中阅读更多信息:http://codex.wordpress.org/Excerpt

关于密码保护,您可以将帖子设置为受密码保护或私密(不同的事情)。在标准 WP 安装中,页面右上角附近有一个“发布”面板来控制此操作。以下是文档: http://codex.wordpress.org/Content_Visibility

提供更复杂的密码保护选项通过插件。

Assuming you mean WordPress 3.1.1, then the answer is that on the page where you author a post there is a place to enter an excerpt. You can read more in the WordPress codex here: http://codex.wordpress.org/Excerpt

Regarding password protection, you can make a post password protected or private (different things). In a standard WP installation there is a "Publish" panel near the top right of the page that controls this. Here is the documentation: http://codex.wordpress.org/Content_Visibility

More sophisticated password protection options are available via plugins.

灼疼热情 2024-11-09 16:24:26

我正在寻找一种解决方案,使摘录在受密码保护的帖子中可用,但我只找到 这种旧的/不起作用的方式,所以我通过将此代码添加到您的主题functions.php中来制作自己的

function gettext_pp( $translation, $text ) {
    if ( $text == 'There is no excerpt because this is a protected post.' ) {
        $post = get_post();
        $translation = $post->post_excerpt;
    }
    return $translation;
}
add_filter( 'gettext', 'gettext_pp', 10, 2 );

方式绕过过滤器“get_the_excerpt”,该过滤器不会在帖子被使用时应用密码保护。

如果您还需要在内容之前显示摘录,您可以这样做:

function excerpt_before_pf( $output ) {
    $post = get_post();
    return $post->post_excerpt . $output;
}
add_filter( 'the_password_form', 'excerpt_before_pf' );

I was looking for a solution to make the excerpt available in a password protected post and I've found only this old / not working way, so I made my own by adding this code to your theme functions.php

function gettext_pp( $translation, $text ) {
    if ( $text == 'There is no excerpt because this is a protected post.' ) {
        $post = get_post();
        $translation = $post->post_excerpt;
    }
    return $translation;
}
add_filter( 'gettext', 'gettext_pp', 10, 2 );

this way you are bypassing the filter "get_the_excerpt" that it's not used applied in case the post is password protected.

If you also need to display the excerpt before the content you can do this:

function excerpt_before_pf( $output ) {
    $post = get_post();
    return $post->post_excerpt . $output;
}
add_filter( 'the_password_form', 'excerpt_before_pf' );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文