我是wordpress的新手,而且我刚刚开始使用自定义页面模板,如果不先登录,就不能让页面上的内容不可见。因此,我从复制基本模板开始:
<?php
/*
Template Name: Full width with no title template
*/
get_header();
?>
<div class="clear"></div>
</header> <!-- / END HOME SECTION -->
<?php zerif_after_header_trigger(); ?>
<div id="content" class="site-content">
<div class="container">
<div class="content-left-wrap col-md-12">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'content', 'page-no-title' );
/* If comments are open or we have at least one comment, load up the comment template */
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
endwhile;
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .content-left-wrap -->
</div><!-- .container -->
</div><!-- .site-content -->
<?php
get_footer();
?>现在,当我打开页面时,系统会提示我输入登录详细信息(我使用的是digimember插件)。但是,现在我想在页面上添加我的自定义内容,所以我在main元素内的php逻辑之后添加了一些HTML标记:
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'content', 'page-no-title' );
/* If comments are open or we have at least one comment, load up the comment template */
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
endwhile;
?>
<h1>Should not be visible but it is</h1>
</main><!-- #main -->现在我仍然看到登录表单,但我也看到了字符串‘不应该可见,但它是’。如何限制此内容?
发布于 2016-08-27 17:33:23
您可以为访问者和渴望的用户设置此条件。
<?php
if ( is_user_logged_in() ) {
echo 'Your Code here !!!';
} else {
wp_login_form( $args );
}
?>有关更多详细信息,请访问此link。
https://stackoverflow.com/questions/39179502
复制相似问题