 |
 |
Wordpress Omit One Post from Query
|
 |
|
 |
|
Moderator 
Join Date: Jun 2000
Location: We come from the land of the ice and snow...
Status:
Offline
|
|
I have googled til my googler is sore. I have scoured the codex. I am going insane.
I have a featured post from a certain category on the home page. In the prev/next pages, I don't want that post to occur. I can get that to happen by skipping that post ID. However the posts per page then becomes off.
This is the query to include just one post:
$wp_query->query('p=5&paged='.$paged);
Other attributes use =- to mean omit, but p=-5 does not work. Neither does p!=5.
Any clue on the query to use? Do I have to get all MySQL on this and bypass wordpress functions?
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by andi*pandi
I have googled til my googler is sore. I have scoured the codex. I am going insane.
I have a featured post from a certain category on the home page. In the prev/next pages, I don't want that post to occur. I can get that to happen by skipping that post ID. However the posts per page then becomes off.
This is the query to include just one post:
$wp_query->query('p=5&paged='.$paged);
Other attributes use =- to mean omit, but p=-5 does not work. Neither does p!=5.
Any clue on the query to use? Do I have to get all MySQL on this and bypass wordpress functions?
Nope, use "post__not_in" w. query_posts():
Template Tags/query posts - WordPress Codex
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Jun 2000
Location: We come from the land of the ice and snow...
Status:
Offline
|
|
Thanks, I'll give it a go!
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Jun 2000
Location: We come from the land of the ice and snow...
Status:
Offline
|
|
That was much more complicated than necessary (grumble grumble args array), but it's working now! Thanks!
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
No problem! I used to concoct my own SQL every one in a while, but I'd find that sometimes I'd paint myself into a corner when I wanted to use a WordPress template tag or some function that only works inside the loop. There might be a way to simulate a WP loop outside of WP, but I've never looked into that. I usually find that once you get past the learning curve that the API does most things that you'll ever want or need.
My only complaint about WordPress is its non MVC design.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |