• Resolved chrismitchell57

    (@chrismitchell57)


    I’m having some issues with a site i’ve built : http://www.newsswipe.co.uk I have made the loop call the same category throughout the index.php offsetting the right number of posts as you can see. But the permalinks are all calling the same post. Below is the code for the index.php

    can anyone explain this?

    <?php get_header(); ?>
    			<div id="block_featured" class="block">
                	<div class="block_inside">
                        <div class="text_block">
                            <div class="hellotext"><?php $posts = get_posts( "category=1&numberposts=1&order=DES" ); ?>
    	<?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    	<img class="imagespacer"
                            <?php
    $szPostContent = $post->post_content;
    $szSearchPattern =  '/src="(.*?)"/';
    
    // Run preg_match_all to grab all the images and save the results in $aPics
    preg_match_all( $szSearchPattern, $szPostContent, $aPics );
    
    // Check to see if we have at least 1 image
    $iNumberOfPics = count($aPics[0]);
    
    if ( $iNumberOfPics > 0 ) {
       // Now here you would do whatever you need to do with the images
       // For this example the images are just displayed
       for ( $i=0; $i < $iNumberOfPics ; $i++ ) {
            echo $aPics[0][$i];
       };
    }; ?>
    align="right" height=200 >
                            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
                        <?php the_excerpt("Continue reading '" . the_title('', '', false) . "'"); ?> 
    
    						<div class="readmorefeatured"><a href="<?php the_permalink(); ?>">Read more...</a></div>
    						<?php endforeach; ?> <?php endif; ?>
    						</div>
                            <br />
                        </div>
                     </div>
                    <div class="greybarmain"></div>
                    <!-- right side -->
    						<div id="minirant"><?php $posts = get_posts( "category=10&numberposts=1" ); ?>
    	<?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    						<h5>MiniRant</h5>
    						<strong><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong>
    						<?php the_content(); ?>
    						<?php endforeach; ?> <?php endif; ?>
    						<br />
    						<a href="rantarchive.php">Read more MiniRants</a>
    						</div>
    						<div id="cartoon">
    						</div>
    				<!--end right side -->
                     <div id="newslist"><div class="newslistnews"><?php $posts = get_posts( "category=1&numberposts=1&offset=1&order=DES" ); ?>
    	<?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    	<h5><a href="<?php the_permalink(); ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h5>
    		<?php the_excerpt(); ?>
    		<div class="readmorefeatured"><a href="<?php the_permalink(); ?>">Read more...</a>
    		<div class="greybarmainsmall"></div>
    <?php endforeach; ?> <?php endif; ?>
    						</div>
                <div class="newslistnews"><?php $posts = get_posts( "category=1&offset=2&numberposts=3&order=DES" ); ?>
    	<?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
                            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    
                        <?php the_excerpt("Continue reading '" . the_title('', '', false) . "'"); ?> 
    
    						<div class="readmorefeatured"><a href="<?php the_permalink(); ?>">Read more...</a></div>
    						<div class="greybarmainsmall"></div>
    						<?php endforeach; ?> <?php endif; ?>
    						</div>
    						<div class="newslistnews"><?php $posts = get_posts( "category=1&offset=5&numberposts=1&order=DES" ); ?>
    	<?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
                            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    
                        <?php the_excerpt("Continue reading '" . the_title('', '', false) . "'"); ?> 
    
    						<div class="readmorefeatured"><a href="<?php the_permalink(); ?>">Read more...</a></div>
    						<?php endforeach; ?> <?php endif; ?></div>
    						<br />
    						<div class="browsearchives"><a href="archives.php">Browse our Archives</a></div>
    						</div>
    
                </div>
    <div class="greybarbottom"></div>
    </div>
    <?php get_footer(); ?>

    Thanks in advance πŸ™‚

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    Set your desired permalink structure and add this code in htaccess:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    ErrorDocument 404 /index.php?error=404
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    Thanks,

    Shane G.

    Thread Starter chrismitchell57

    (@chrismitchell57)

    Hi Shane,

    Thanks for your help.. I have changed the code in the .htaccess but still having the same problem πŸ™ I don’t know what else it could be.

    Thanks

    Chris

    Thread Starter chrismitchell57

    (@chrismitchell57)

    bump

    Thread Starter chrismitchell57

    (@chrismitchell57)

    I know that this problem has existed in the past on this forum but i can’t find any solution? Any help?

    Thread Starter chrismitchell57

    (@chrismitchell57)

    Ok I resorted to installing version 2.8.6 and still there are the same issues! Is this something to do with the `<?php $posts = get_posts( “category=10&numberposts=1” ); ?>
    <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>` loop? As I read on another post that someone fixed it by removing that element. Though how I get a post to call just from a single category without that loop I don’t know.

    Any Ideas?

    Thread Starter chrismitchell57

    (@chrismitchell57)

    bump

    please can anyone help me with this?

    Thread Starter chrismitchell57

    (@chrismitchell57)

    bump!

    anyone?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘permalinks all going to the same post’ is closed to new replies.