individuelles und professionelles Webdesign, Programmierung und Internetmarketing

Exclude one headline post from frontpage but not if is paged

The problem: I got a WordPress site with feature headline, the latest post of headline category.
Below I want to show all posts from all categories except this one.
But I want to display older posts from this category headline together with any post of any other category.
Next problem with this site, on frontpage have to be 6 posts plus the headline, on following pages is no headline and there should be displayed more posts.

Live on Great Geadgets

This is how I solved this problem for me, the name for that headline category is Headline with ID 6.

the first loop:
<?php get_header(); ?>
<?php if(!is_paged()) { ?>

<?php query_posts(“showposts=1&category_name=Headline”); //retrieves 1 post from headline ?>
<?php while (have_posts()) : the_post(); ?>
<?php $do_not_duplicate = $post->ID; ?>

now do stuff for first post like title and content

<?php endwhile; ?>

<?php } //end if is only not paged headline post ?>

Now I start a loop quering for all posts and leaving the one above out:

<?php
$page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$num_of_posts = get_option(‘posts_per_page’);
if ( !is_paged()){
query_posts(“cat=-6&paged=$page&posts_per_page=6″);
} else {
query_posts(“paged=$page&posts_per_page=$num_of_posts”); } ?>
<?php $i = 1; ?>
<?php while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
<?php if ( $paged < 2 ) { ?>

now do stuff for first page, limited to 6 post and exclude category Headline (ID 6) from that loop, here is the place to style the frontpage and the way how to display posts.

<?php } else { //now if is paged ?>

do stuff for following pages and take the number of pages from the settings in options

<?php } //end if else paged ?>

<?php endwhile; ?>

<div class=”navigation”> This comes normally close to the end of a template

It would be great to exclude a single post by post ID from the second loop, I did not find an easy way for that yet. I mean something like query_posts and exclude a post by $post->ID what you can get from the first loop

Related posts:

  1. List one latest post per category on frontpage view
    I will give you here a code to list only...
  2. Add Adsense between some Posts in WordPress
    In WordPress on the frontpage you have normally a flow...
  3. Category view in Arthemia optimized
    Question: Can you display headline & featured block to each...
  4. list pages custom styling in arthemia category bar
    Some users of of arthemia theme would like to display...
  5. List some pages with content in WordPress
    To list pages in WordPress you normally take this: <?php...
2. December 2008 • Kategorie: Wordpress Tips Tags: , ,
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Facebook
  • LinkedIn
  • TwitThis

JW ist Freelance Webdeveloper

Website Questions? Please ask in Webdesign Forum


You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

ein Kommentar »

  1. Please stop pulling my hair! ..

Kommentieren

Interessante Links zu exclude post WordPress

The Loop - WordPress Codex

When WordPress documentation states "This tag must be within The Loop", such as for specific Template Tag or plugins, the tag will be repeated for each post. ...

Tags: wordpress, codex,
How to Exclude Latest Post from the WordPress Post Loop

How to Exclude Latest Post from the WordPress Post Loop by using the offset parameter in wp_query. This will allow you to exclude latest posts from your post loop.

Tags: exclude, latest, wordpress,
WordPress " Support " Exclude post in sidebar based on selection

However I don't know how to exclude the post in the middle from the sidebar? ... This would exclude, in this instance, the post with the ID of 31. ...

Tags: wordpress, support, exclude, sidebar,
How to Exclude a Category from the Home Page

This is the  most common customization requests for WordPress, How do I prevent posts from a certain category from displaying on my home page?!   As I have

Tags: exclude, category,
Fadi Hania Blog » WordPress: Categorize Posts in Pages

This article describes how to categorize posts in pages by modifying your theme template to show posts belonging to a specific category, and to exclude these posts from your home page.

Tags: hania, wordpress, categorize, posts,
Acrez

Profi WordPress theme with five colour schemes, two/three columns, six widget areas and tons of functions. Automatic post thumbnail, Featured posts, Control Panel in sidebar, Dropdown page and category menu. Powerful theme options menu (including: Logo change, Exclude categories feature, Category description, Customizable sidebar layout, great Ads

Tags: acrez,
Nützliche WordPress-Plugins für Kundenprojekte

5. Exclude Pages Eine praktischen Funktion ... Ähnliche Artikel zu diesem Thema WordPress Tipp: Post Editor Buttons

Tags: ntzliche, wordpress-plugins, kundenprojekte,
Problem beim Variabeln übergeben für tag cloud

Code: <?php wp_tag_cloud(array('exclude' => getZahlen ... get_results("SELECT meta_value, post_id FROM $wpdb

Tags: problem, variabeln, bergeben, cloud,
Persistenz mit JPA und Google App Engine

Nur die Zeile “<exclude-unlisted-classes>false</exclude-unlisted-classes>” hat bei mir im weiteren Verlauf

Tags: persistenz, google, engine,