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">
            //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();
                    <div class="alingRight">
                        echo the_post_thumbnail();

    <?php   endwhile;   
        </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" />
              <div class="clr"></div>
    <?php get_sidebar(); ?>
 <?php get_footer(); ?>

And here is the majority of the profile view page:


                echo "<script>
                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);
                    echo "<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">

        <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 class="alignRight">
                <div class="left"><i><?php _e('About Me:', 'soodba');?></i>
                    <p> <?=the_author_meta( 'description', $getId); ?></p>
                <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 class="clr"></div>
                <div class="contact"><strong><?php _e('Contact information:', 'textdomain');?></strong> <?= get_the_author_meta('user_email', $getId );?></div>
             <div class="clr"></div>

     <?php if ( is_active_sidebar('inner')): ?>
    <div id="wrapper3rd">
      <div id="innerSidebarContent">
     <?php dynamic_sidebar( 'inner' ); ?>

    <?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?


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.

  • Added some answers to questions I found solutions for and accepted some answers when they were correct. Now let's crack this one..
    – rhand
    Mar 17 '12 at 6:38
  • cool mate - hope my answer helps - update me if you need additional help - would try my best :)
    – Sagive
    Mar 17 '12 at 14:18

why not make author.php page where you can design it and load stuff as you wish?
do you have that?

Anyhow try to wrap the entire div class=slider with this since maybe
your home page is index.php and not a page template... :

<?php if(is_home() || is_front_page()) { ?>

<div class="slider">
All the slider stuff here..

<?php } else } ?>

i am not the homepage!

<?php } ?>

Hope this helps.. Cheers, Sagive

  • Well, I guess the profile page is an author page with several author_meta fields so I could have done that too. Not sure if I can migrate all easily to a public author page and keep the access code rule running. Going to try your conditional tag now.
    – rhand
    Mar 17 '12 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.