Support » Fixing WordPress » All sidebar loop post links points to one post

  • I’m making new theme and added a separate sidebar using sidebar.php file and added a current category loop using the following script :

    [please mark any posted code; see – the code below is partially broken]

    									$query = "showposts=4&orderby=date&cat="; 
    									foreach((get_the_category()) as $category) {
    									    $query .= $category->cat_ID .",";
    																	global $mainPostID;
    									if ( !empty($mainPostID) && is_single() )
    									    $query .= "&post__not_in=" . $mainPostID;
                  <?php while (have_posts()) : the_post(); ?>
                             <div class="hero-post-image-thumb" style="background-image: url('<?php echo $image[0]; ?>')">
                     							<a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                             <h5 class="hero-sidebar-title">
                                 <?php the_title(); ?>
                             <span class="hero-since-time">
                             <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
    <?php endwhile; ?>

    And added a loop like the following in my single.php file :

    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
                                            <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
                                            <div class="post" id="post-<?php the_ID(); ?>">
                                            <div class="hero-single-post-image" style="background-image: url('<?php echo $image[0]; ?>') ; "></div>
                                            <div class="hero-up-onair">
                                            <div class="hero-title">
                                            <h2><a>" title="<?php the_title(); ?>">
                                            <?php the_title(); ?></a></h2>
                                                <div class="author">BY <b><?php the_author(); ?></b></div>
                                            <div class="hero-post">
                                                <h5><?php the_content(); ?></h5>
                                            <p class="postmetadata">
                                            <?php edit_post_link('Edit', ' | ', ''); ?>
                                            <?php endwhile; ?>
                                            <?php endif; ?>

    And while testing the theme i found that when user clicked a sidebar loop link which is pointing to post y from a post X then the user will get redirected to the same post X , You can simply checkout a preview of this on my test page : . It’s an urgent work exactly and thanks in advance …

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘All sidebar loop post links points to one post’ is closed to new replies.