如果用户在主页上输入一个代码,并且该代码有效,他们将被发送到显示个人资料的帖子类型页面。问题是,不知何故主页滑块也会显示在个人资料页面上。不知怎的,它也加载了,我不想这样。我尝试使用条件卸载它,但这似乎不起作用。以下是主页代码:
<?php get_header(); ?>
<div id="wrapper2nd">
<div class="content">
<div id="slider">
<ul>
<?php
//if ( \'viewprofile\' !== get_post_type() ) {
$args = array( \'post_type\' => \'slider\', \'posts_per_page\' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<li>
<div class="alingRight">
<?php
the_content();
echo the_post_thumbnail();
?>
</div>
</li>
<?php endwhile;
//}
?>
</ul>
</div> <div class="container">
<form action="<?php echo get_option(\'home\'); ?>?post_type=viewprofile" method="post">
<span><?php _e(\'If you received a Card,</br> enter the code here:\', \'textdomain\');?></span><input name="myaccesskey" type="text" class="inputBox" /><input type="submit" value="<?php _e(\'Go\', \'textdomain\');?>" class="go" />
</form>
</div>
<div class="clr"></div>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
以下是纵断面图页面的大部分内容:
<?php
if(empty($_REQUEST[\'myaccesskey\'])){
echo "<script>
location.replace(\'".$_SERVER[\'HTTP_REFERER\']."\');
</script>";
}else{
global $wpdb;
$getId = null;
$getCode = $_POST[\'myaccesskey\'];
$querystr = $wpdb->prepare("SELECT user_id FROM wp_x_usermeta WHERE meta_key=\'myaccesskey\' AND meta_value=\'%s\'",$getCode);
$querystrChecking = mysql_query($querystr);
if(mysql_num_rows($querystrChecking)<=0){
echo "<script>
location.replace(\'".$_SERVER[\'HTTP_REFERER\']."\');
</script>";
}
elseif ($row = mysql_fetch_assoc($querystrChecking)) {
$getId = $row[\'user_id\'];
}
$uploads = wp_upload_dir();
//
}
?>
<?php get_header(); ?>
<div id="wrapper2nd" class="inner">
<div class="content" id="inner">
<h1>PROFILE</h1>
<div id="profileView">
<div class="alignLeft">
<strong><?php _e(\'Name:\', \'textdomain\');?></strong> <?php the_author_meta( \'first_name\', $getId ); ?> <?php the_author_meta( \'last_name\', $getId); ?><br />
<strong><?php _e(\'Nick Name:\', \'textdomain\');?></strong> <?php the_author_meta( \'nickname\', $getId ); ?><br />
<strong><?php _e(\'Age:\', \'textdomain\');?></strong><?php get_the_author_meta( \'dateofbirth\', $getId );?><br />
<?=get_the_author_meta( \'myfavouritelinks\', $getId );?>
</div>
<div class="alignRight">
<div class="left"><i><?php _e(\'About Me:\', \'soodba\');?></i>
<p> <?=the_author_meta( \'description\', $getId); ?></p>
</div>
<div class="right">
<?php if(get_the_author_meta( \'userphoto_thumb_file\', $getId )!=""){?>
<img src="<?=$uploads[\'baseurl\'];?>/thumbs/<?=get_the_author_meta( \'userphoto_thumb_file\', $getId );?>" />
<?php }?>
<a href="#" class="allpic"><?php _e(\'see all pictures\', \'textdomain\');?></a>
</div>
<div class="clr"></div>
<div class="contact"><strong><?php _e(\'Contact information:\', \'textdomain\');?></strong> <?= get_the_author_meta(\'user_email\', $getId );?></div>
</div>
<div class="clr"></div>
</div>
</div>
</div>
<?php if ( is_active_sidebar(\'inner\')): ?>
<div id="wrapper3rd">
<div id="innerSidebarContent">
<?php dynamic_sidebar( \'inner\' ); ?>
</div>
</div>
<?php endif; // end sidebar widget area ?>
<?php get_footer(); ?>
我尝试了其他条件,例如
if (is_page() || is_front_page())
, 但滑块仍加载在
get_the_author_meta
细节,我想它仍然是头版的一部分???。有没有办法解决这个问题?
Update
似乎纵断面图是作为子字符串url加载的
http://www.domain.com/?post_type=viewprofile - 的索引。php。我的意思是,个人资料页面似乎是索引的一个附加部分,而它应该是一个单独的页面。不知何故,我的编码错误地加载了索引。PHP代码
Update 2
我给自定义帖子打了一个鼻涕:
register_post_type(\'profile\', array(
\'label\' => __(\'Profile\'),
\'singular_label\' => __(\'Profile\'),
\'public\' => true,
\'show_ui\' => false, // UI in admin panel
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => array("slug" => "user-profile"), // Permalinks format
\'supports\' => array(\'title\',\'author\')
));
现在条件确实起作用了。滑块未加载。但是profileviewpage代码也不是。