WordPress.org

Forums

All sidebar loop post links points to one post (4 posts)

  1. Mostout_DV
    Member
    Posted 1 year ago #

    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 http://codex.wordpress.org/Forum_Welcome#Posting_Code - the code below is partially broken]

    <?php
    									$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;
    
    									query_posts($query);
    									?> 
    
    <ul>
                  <?php while (have_posts()) : the_post(); ?>
    
    <li>
                             <div class="hero-post-image-thumb" style="background-image: url('<?php echo $image[0]; ?>')">
    
                             </div>
                     							<a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                             <h5 class="hero-sidebar-title">
                                 <?php the_title(); ?>
                             </h5>
                             </a>
                             <span class="hero-since-time">
                             <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
                             </span>
        </li>
    <?php endwhile; ?>
    </ul>

    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>
    
                                            <div class="hero-post">
                                                <h5><?php the_content(); ?></h5>
    
                                            <p class="postmetadata">
                                            <?php edit_post_link('Edit', ' | ', ''); ?>
                                            </p>
    
                                            </div>
                                            </div>
                                            <?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 : ciaptica.byethost16.com/ko . It's an urgent work exactly and thanks in advance ...

  2. Mostout_DV
    Member
    Posted 1 year ago #

  3. Mostout_DV
    Member
    Posted 1 year ago #

    In single.php the posts are getting repeated too

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    unfortunately, your above posted codes got broken;

    please re-post the codes, either marking them properly or using the pastebin as described in http://codex.wordpress.org/Forum_Welcome#Posting_Code

Topic Closed

This topic has been closed to new replies.

About this Topic