还是决定把 status.dun4real.org 未登录用户的首页和侧边栏禁掉了
现在未登录时打开时是这样的(改了一下 index.php 和 sidebar.php 的规则)
附修改后的 index.php
<?php
/**
* Main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package P2
*/
?>
<?php get_header(); ?>
<div class="sleeve_main">
<?php if ( is_user_logged_in() ) : ?>
<?php if ( p2_user_can_post() && !is_archive() ) : ?>
<?php locate_template( array( 'post-form.php' ), true ); ?>
<?php endif; ?>
<div id="main">
<h2>
<?php if ( is_home() or is_front_page() ) : ?>
<?php _e( 'Recent Updates', 'p2' ); ?> <?php if ( p2_get_page_number() > 1 ) printf( __( 'Page %s', 'p2' ), p2_get_page_number() ); ?>
<?php else : ?>
<?php printf( _x( 'Updates from %s', 'Month name', 'p2' ), get_the_time( 'F, Y' ) ); ?>
<?php endif; ?>
<span class="controls">
<a href="#" id="togglecomments"> <?php _e( 'Toggle Comment Threads', 'p2' ); ?></a> | <a href="#directions" id="directions-keyboard"><?php _e( 'Keyboard Shortcuts', 'p2' ); ?></a>
</span>
</h2>
<ul id="postlist">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php p2_load_entry(); ?>
<?php endwhile; ?>
<?php else : ?>
<li class="no-posts">
<h3><?php _e( 'No posts yet!', 'p2' ); ?></h3>
</li>
<?php endif; ?>
</ul>
<?php if ( p2_user_can_post() ) : ?>
<div class="navigation">
<p class="nav-older"><?php next_posts_link( __( '← Older posts', 'p2' ) ); ?></p>
<p class="nav-newer"><?php previous_posts_link( __( 'Newer posts →', 'p2' ) ); ?></p>
</div>
<?php endif; ?>
</div> <!-- main -->
<?php else : ?>
<h2>This is a private WordPress blog. </h2><h2><a href="/wp-admin">Log in</a> to view this site, or <a href="/wp-login.php?action=register">sign up</a> for a visitor account.</h2>
<?php endif; ?>
</div> <!-- sleeve -->
<?php get_footer(); ?>
moonshimmer 12:28 pm on December 30, 2023 Permalink |
改的原因是,首页所在页面设为私密是不起效果的。同时,我也不想在设置里面把整个站点设为私密。虽然首页和侧边栏仅登录可见,所有的页面和帖文目前都是公开的。
moonshimmer 12:32 pm on December 30, 2023 Permalink |
这有点像 Instagram,至少以前是私密账户分享的照片还是可以被所有人看到的,但是他们如果没有链接就看不到其他照片。