gpt4 book ai didi

Wordpress 密码保护存档和自定义帖子类型的单个帖子

转载 作者:行者123 更新时间:2023-12-01 10:59:14 24 4
gpt4 key购买 nike

有没有一种简单的方法来密码保护自定义帖子类型的存档和单个帖子?

我找到了这篇关于密码保护单个帖子的文章,但仍然在存档循环中丢失了。我希望它只显示密码框,直到用户登录。

https://wordpress.stackexchange.com/questions/4952/forcing-all-posts-associated-with-a-custom-post-type-to-be-private

谢谢,

最佳答案

我发现快速密码保护存档的唯一方法是创建一个模板来检索自定义帖子类型数据并将其与可以密码保护的页面相关联。
http://codex.wordpress.org/Page_Templates

一旦该页面受密码保护,您就会找到帖子 ID 以将其应用到单 {your_custom_post_type}.php 中,如下所示:

<?php
if ( !post_password_required('{protected_post_id}') ) : ?>

//protected content here

<?php else:
//show the password form of the protected page
echo get_the_password_form('{protected_post_id}');

endif; ?>

这使您不必对自定义帖子类型下的每个帖子进行密码保护。

关于Wordpress 密码保护存档和自定义帖子类型的单个帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12822923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com