Wordpress problem..

C

chrismitchell

Guest
Someone might be able to help with this...

I'm making a new site called Newsswipe.. its for my fiance and me to complain about the world :)

now i'm having some stupid issue with the hyperlinks to the posts.. for some reason or another its only opening the newest post.. on all the links... any idea why and how to make it open the correct post from the list.

have a looksee at Newsswipe | Attacking the News from all sides!
 
Hi Chris, what's the code your using?

Must be that...
you have single.php doing a wp_query to show most recent post
or that your just using index.php so the single post is seeing that?

can't really see how you would have messed up the actual links themselves to do that?
 
checked the source and your links are correct so must be a single.php / index.php problem?
 
thats what I thought too mate.. I just can't figure it out off the top of my head :confused:

i'm sure that the code i'm using has worked before on a different site (as I made it work for my past company that I worked for).. but for some reason I can't get this to work.. its very perplexing.

I will keep trying :)
 
Your problem will be on what ever this page goes to locally ~
test post | Newsswipe | Attacking the News from all sides!

I imagine it's a problem with referencing the get variable are you using a constant to bring the data from the DB by mistake?
That would explain it TBH, as in the constant is set to the last article and not the number from the get. That mistake during testing does sound like it TBF.

Got any code we can look at from that page, the query would be great, obviously don't post table names or access details. Change them to SELECT var1,var2,var3,var4 FROM table1 WHERE var1= as that wont be needed.

Alternatively look at the WHERE clause of your query.

Jaz
 
the code from the index.php to call the 2nd news item in the list is:

PHP:
<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>

and the code on the single-default.php is:

PHP:
<?php get_header(); ?>
			            <div class="mini_portfolio_item_page_event1">
                    	<div class="block_inside_event">
                    	 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h3><?php echo the_title(); ?></h3>
<br />	
				<?php echo the_content(); ?>

<?php wp_related_posts(); ?>


	<?php endwhile; ?>

		<p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>
							</div>                    
                    </div>
            
            <br />
                    <!-- right side for events -->
            
            
    </div>
<?php get_footer(); ?>

Can't see the error myself :lol: but if someone else can see what the hell i've done wrong that would be great :D
 
I reckon heres your problem ~
get_posts( "category=1&numberposts=1&offset=1&order=DES")
As offsets looks like it is a constant it more than likely needs to by dynamic.

I imagine category is well the category, number of posts limits it to just 1 for the page, offset then pluses 1 to the limited amount and order in descending order.

So as that's more than likely your mysql query as in it gets translated to ~

SELECT * FROM table_name WHERE category ='1' ORDER_BY desc LIMIT 1 OFFSET 1

Which should get you the 2nd result if that's how it is put together.

As in that selects everything from a table called table_name where the category name equals 1 it is then order in descending order and limited to the first result which is then offset by 1 so the second result would be retrieved.

So if every-page is loading that same line unchanged the query will always be the same and the second row will always be got as that is how the query probably gets put together.

Try incrementing the offset by 1, which should get you the third article and see if that fixes it if it does you need to make the offset dynamic using the get variable. :)

Jaz
 
Which is which page, the top one a snippet from the index page and the bottom one from the test-article page?
 
Hi Jaz :) thanks for looking mate.. but the offset increment didn't change the issue.. I wonder if its some sort of internal error with Wordpress... I might have to send an email to wordpress people to find out :confused:
 
the top one is the call for the excerpt and link on the index page and the bottom one is the actual default template for the single post.
 
Right cool then that will just change the home page not the problem page, right hold on I'll have another look. :)
 
What's getheader?
As those lines are oupting the query so if they have already got it then they will just output the same does that makes sense.
 
getheader is the dynamic call in wordpress to call the header.php template above it and there is a getfooter too that calls the footer.php template underneath.
 
Chris I'm going to email you a single.php file. Once you get it back up your current one and replace with this on the server - at least that way you will know if that's the problem!
 
Hey Andy :) thanks for sending that file.. but its defo not a problem on the single.php :( it must be a problem with my call function on the home page :confused:
 
Hay fella sorry, been helping my mother move into her new house 2 days before xmas, nothing like VAT and stamp duty going back up in Jan for getting solicitors to shift their fat asses at the last min now is there. :D

Right where is the query for the article page?
Be it a function or an actually query.
If it is a actual query I don't need to see the table name or variables that it is getting just the order and the variables are being sent to it and what the where clause is, again doesn't need to be the exact row name, but as long as it is obvious.
So if it is~
SELECT article_name,date_added,comments,content FROM article WHERE cat=....

You could replace it as ~
SELECT var1,var2,var3,var4 FROM table_name WHERE category=......

If you get me.

Because the get variable looks like it is being past over fine in the URL so it is probably a problem with a constant in the query, hence why I got mixed up with the pages. :)

Jaz
 
Back
Top