If users enter a code on the homepage and that code is valid they will be sent to a post type page where a profile is shown. The issue is that somehow the homepage slider is shown on that profile page too. Somehow it is loaded as well and I do not want that. I tried to unload it using a conditional, but that does not seem to work. Here is the homepage code:
<?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(); ?>
And here is the majority of the profile view page:
<?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(); ?>
I tried other conditionals such as if (is_page() || is_front_page()), but the slider is still loaded on the profile page underneath the get_the_author_meta details as I guess it is part of the front page still???. Any ideas how to fix this?
Update
It seems that profile view is loaded as a substring - url http://www.domain.com/?post_type=viewprofile - of index.php. I mean, the profile page seems to be an addition of the index, while it should be a separate page. Somehow my coding is incorrectly loading index.php code
Update 2
I gave the custom post a slug using:
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')
));
and now the conditional does work. The slider is not loaded. But the profileviewpage code is not yet either.