Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Yeah, still have some open questions. Did answer some myself already. But will look into this. Will accept rate go up when I answer my own questions then? Will see –  rhand Mar 17 '12 at 5:16
    
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 SEO Mar 17 '12 at 14:18
add comment

1 Answer

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..
</div>

<?php } else } ?>

i am not the homepage!

<?php } ?>

.
Hope this helps.. Cheers, Sagive

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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