Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Wordpress loop screwing up

Featured Replies

Hey,

 

My mate has a website with loads of blog posts. On the first page, it shows the first 5, then uses pagination, to go further back.

 

I made a simple loop, so that the first post shows all the content, and then the rest just the excerpt.

 

First problem (not major).

 

But everytime the page goes back (so page 2, 3 etc) the first is still showing the full content (as the loop counter resets). Does anyone know a way around that?

 

Second (biggest issue):

 

He wants to exclude some posts from the main blog roll. So he made a new category called 'Exclude' (ID = 771), and before the blog roll loop stars, I put in:

 

<?php query_posts( 'cat=-771' ); ?>

 

This works, however now the pagination doesn't. So clicking "Older Posts" changes the link so page-2, however the posts (5 latest) dont change.

 

Sorry for the ramble, any help would be awesome :)

query_posts tends to replace arguments rather than adding to them. Try:

$args = array(
'cat' => '-771');
query_posts(array_merge($args, $wp_query->query));

 

Should sort out your pagination. First post needs to test for $_GET['paged'], which is the var WP uses.

Edited by Renaissance-Design

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.