Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Sidebar displaying incorrectly in loop WordPress

  • SOLVED

I need some work done on my website hope you are available. Here is what I need

1. Fix author page - I have a custom author page (loop-author.php) but it is not displaying properly. The sidebar for author page is appearing after posts grid instead of before. I would like to fix it so sidebar appears first and then post grid.

Please see this link for example of problem http://watchthefeed.com/author/icanhazgiraffe/

here is my loop author template:

<?php get_header(); ?>


<?php
if ( have_posts() ) :
/* Anything placed in #sort is positioned by jQuery Masonry */ ?>
<div id="sort">
<?php while ( have_posts() ) : the_post();

global $my_size, $force_feat_img, $embed_code, $vid_url;

// Gather custom fields
$embed_code = get_post_meta($post->ID, 'soy_vid', true);
$vid_url = get_post_meta($post->ID, 'soy_vid_url', true);
$force_feat_img = get_post_meta($post->ID, 'soy_hide_vid', true);
$show_title = get_post_meta($post->ID, 'soy_show_title', true);
$show_desc = get_post_meta($post->ID, 'soy_show_desc', true);
$box_size = get_post_meta($post->ID, 'soy_box_size', true);

if( $box_size == 'Medium (485px)' ){
$my_size = 'col3';
$embed_size = '495';
} else if( $box_size == 'Large (660px)' ){
$my_size = 'col4';
$embed_size = '670';
} else if( $box_size == 'Tiny (135px)' ){
$my_size = 'col1';
$embed_size = '145';
}else{
$my_size = 'col2';
$embed_size = '320';
}

/* Check whether content is being displayed
* This determines whether a border should be applied
* above the postmeta section
*/
if($show_title != 'No'){
$content_class = 'has-content';
} else if($show_desc != 'No' && $post->post_content){
$content_class = 'has-content';
}else {
$content_class = 'no-content';
}

// Assign categories as class names to enable filtering
$category_classes = '';

foreach( ( get_the_category() ) as $category ) {
$category_classes .= $category->category_nicename . ' ';
}
?>

<div class="all box <?php echo $category_classes . $my_size; ?>">

<div <?php post_class( 'box-content '.$content_class ) ?>>
<?php
// Display video if available
if( ( $embed_code || $vid_url ) && !$force_feat_img ):

if( $vid_url ){
echo '<div class="vid-container">'.apply_filters('the_content', '[embed width="' . $embed_size . '"]' . $vid_url . '[/embed]').'</div>';
} else {
echo '<div class="vid-container">'.$embed_code.'</div>';
}

// Display gallery
elseif( has_post_format( 'gallery' ) && !$force_feat_img ):

get_template_part( 'includes/loop-gallery' );

// Display featured image
elseif ( has_post_thumbnail() ): ?>

<div class="img-container">
<?php
// Display the appropriate sized featured image
if( $my_size != 'col2' ): ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail($my_size, array( 'class' => 'feat-img' ) ); ?></a>
<?php else: ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-thumbnail', array( 'class' => 'feat-img' ) ); ?></a>
<?php endif;

// Display View/Share/Comment buttons
if( !of_get_option( 'hide_action_buttons' ) ) :
get_template_part( 'includes/action-buttons' );
endif; ?>
</div><!-- #img-container -->

<?php if( has_post_format( 'gallery' ) ) get_template_part( 'includes/gallery-list' ); ?>

<?php endif; // #has_post_thumbnail() ?>

<div class="post-content">

<?php // Display post title
if( $show_title != 'No' && !has_post_format('quote') ): ?>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark">
<?php the_title(); ?>
</a></h2>
<?php endif;

// Display post content
if( is_search() && $show_desc != 'No' ):

the_excerpt(); // Only display excerpts for search results

elseif( $show_desc != 'No' ):

if( has_excerpt() ){
the_excerpt();
}
endif; ?>

<?php edit_post_link(__('Edit this post', 'shaken')); ?>
</div><!-- #entry -->

<?php // Display post footer
if( $my_size != 'col1' ): ?>
<div class="post-footer">
<span class="category-ic"><?php the_category(', '); ?></span>
<a href="<?php echo wp_get_shortlink(); ?>" class="shortlink tooltip" title="Shortlink"><?php _e('Shortlink', 'shaken'); ?></a>
</div>
<?php endif; ?>

</div><!-- #box-content -->
</div><!-- #box -->
<?php endwhile; ?>
</div><!-- #sort -->

<?php // Display pagination when applicable
if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older', 'shaken') ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer <span class="meta-nav">&rarr;</span>', 'shaken') ); ?></div>
<div class="clearfix"></div>
</div><!-- #nav-below -->
<?php endif; ?>

<?php else :
/* If there are no posts */ ?>
<div id="sort">
<div class="box">
<div class="box-content not-found">
<h2><?php _e('Sorry, no posts were found', 'shaken'); ?></h2>
<?php get_search_form(); ?>
</div><!-- #not-found -->
</div>
</div><!-- #sort -->
<?php endif; ?>
<?php get_sidebar(author); ?>
<?php get_footer(); ?>


Any ideas? Thanks

Answers (3)

2014-04-18

Hariprasad Vijayan answers:

Hello George,

In your code, <?php get_sidebar(author); ?> is just above footer. Please place it below <?php get_header(); ?>

Let me know if you need help.

Thanks.


George Sprouse comments:

Thanks hariprasad! Completely slipped my my mind to move side bar. thanks again

2014-04-18

Arnav Joy answers:

Everything is messed up in your site , can you show mockup how you want it to look?

2014-04-18

Sébastien | French WordpressDesigner answers:

replace
<?php get_sidebar(author); ?>
by
<?php get_sidebar('author'); ?>

If sidebar-author.php does not exist, then it will fallback to loading sidebar.php