<?php 
if(10 == 10): 
echo ‘This is true, and will be shown.’; 
endif; 
if(10 == 15): 
echo ‘This is false, and will not be shown.’; 
endif; 
?> 
 
<?php 
if(10 == 11): 
echo ‘This is false, and will not be shown.’; 
elseif(10 == 15): 
echo ‘This is false, and will not be shown.’; 
else: 
echo ‘Since none of the above is true, this will be shown.’; 
endif; 
?> 
 
<?php 
if( is_home() ): 
echo ‘User is on the homepage.’; 
else: 
echo ‘User is not on the homepage’; 
endif; 
?> 
 
<?php 
if( is_home() AND is_page( 5 ) ): 
echo ‘User is on the homepage, and the home pages ID is 5′; 
endif; 
if( is_home() OR is_page( 5 )): 
echo ‘User is on the homepage or the page where the ID is 5′; 
endif; 
?> 
 
<?php if ( have_posts() ) : ?> 
… posts … 
<?php else : ?> 
… search field … 
<?php endif; ?> 
 
if( is_admin() ): 
# User is administator 
endif; 
if( is_home() AND is_page(’1′) ): 
# The user is at the home page and the home page is a page with the ID 1 
endif; 
if( is_single() OR is_page() ): 
# The user is reading a post or a page 
endif; 
if( !is_home() AND is_page() ): 
# The user is on a page, but not the homepage 
endif; 
 
if ( is_user_logged_in() ): 
echo ‘Welcome, registered user!’; 
else: 
echo ‘Welcome, visitor!’; 
endif; 
 
<?php if ( get_option(‘users_can_register’): 
echo ‘Registrations are open.’; 
else: 
echo ‘Registrations are closed.’; 
endif; 
判别用户应用的电脑是pc或mac 
if( stristr($_SERVER['HTTP_USER_AGENT'],”mac”) ): 
echo ‘Hello, I’m a Mac.’; 
else: 
echo ‘And I’m a PC.’; 
endif; 
 
<?php 
// function for inserting Google Analytics into the wp_head 
add_action(‘wp_footer’, ‘ga’); 
function ga() { 
if ( !is_user_logged_in() ): // íf user is not logged in 
?> 
<script type=”text/javascript”> 
var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']); // insert your Google Analytics id here 
_gaq.push(['_trackPageview']); 
_gaq.push(['_trackPageLoadTime']); 
(function() { 
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true; 
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’; 
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s); 
})(); 
</script> 
<?php 
endif; 
} 
?> 
 
<?php if ( is_singular( ‘books’ ) ): 
// This post is of the custom post type books. 
endif; ?> 
 
<?php 
add_action(‘template_redirect’, ‘single_result’); 
function single_result() { 
if (is_search()) { 
global $wp_query; 
if ($wp_query->post_count == 1) { 
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) ); 
} 
} 
} 
?> 
 
<?php if( ($wp_query->current_post + 1) < ($wp_query->post_count) ): ?> 
<p class=”separator”></p> 
<?php endif; ?> 
 
<?php 
if( current_user_can(‘editor’) ): 
// true if user is an editor 
endif; 
if( !current_user_can(‘administrator’) ): 
// true if user is not admin 
endif; 
if( current_user_can(‘edit_posts’) ): 
// true if user can edit posts 
endif; 
?> 
 
<?php 
add_filter( ‘wp_default_editor’, create_function(”, ‘return “tinymce”;’) ); 
add_action( ‘admin_head’, ‘disable_html_editor_wps’ ); 
function disable_html_editor_wps() { 
global $current_user; 
get_currentuserinfo(); 
if ($current_user->user_level != 10) { 
echo ‘<style type=”text/css”>#editor-toolbar #edButtonHTML, #quicktags {display: none;}</style>’; 
} 
} 
?> 
以上就是安达网络工作室关于《WordPress自带的条件标签使用说明》的一些看法。更多内容请查看本栏目更多内容!
缺点文件/{Path}/wp-includes/registration-functions.php 要害代码: —-> <?php /** * Deprecated. N...
自己2012年12月20日左右接触wordpress,至今曾经两个月。由于以前丝毫没有网站治理经历及编程才能,因而...
关于日拜访量还不错的WordPress网站来说,一定都会存在很多待审核的渣滓评论,假如要经过WP后盾删除,那几乎...
提示用户以后主题需求的插件 很多主题都需求一些插件的支持,这时你就需求提示用户需求装置的插件,本文将教...
WordPress根本模板文件 一套完好的WordPress模板应至多具备如下文件: style.css : CSS(款式表)文件 index....
某天用360的破绽检测,总共用了56分钟才检测完。 检测后果如图:破绽修复 破绽文件:(依据报警信息,修正这...