WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP CMS, list of the post as a blog page (9 posts)

  1. freeriders
    Member
    Posted 6 years ago #

    Greetings

    I want to use WP as a CMS, where one of the part of the site is a blog, called blog, with all the post there and the other part of the site are WP Pages actually.. so I would have Home - Blog - About ..

    for the blog part, I make a WP Page called blog, with a sug as blog, and which I link to a template for that specific page.. on my permalink structure I have putted for the custom /blog/%postname%/

    my template is as such (it takes the normal loop, just added query_posts('cat=-0')

    <?php
    /*
    Template Name: tpl_Blog
    */
     get_header();
    	query_posts('cat=-0')
    	?>
    	<div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', ''); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.
    
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php // get_sidebar(); ?>
    
    <?php get_footer(); ?>

    it works pretty well actually

    let say it shows me the 3 last post called H, G, F

    but I have a problem when I try to get it paginated..

    when I hit the "older entries" link, it well direct me to /blog/page/2/ fine

    BUT

    the post listed are the same, the last 3 post H, G, F and NOT post E, D, C as I would have expected..

    any ideaof what I'm doing wrong?

    thank you VERY much in advance

    Steffy

  2. moshu
    Member
    Posted 6 years ago #

    What is this zero doing?
    query_posts('cat=-0')

  3. freeriders
    Member
    Posted 6 years ago #

    well I got this somewhere I think, it is to list ALL the categories..

    do I am wrong?

    how would you do?

  4. Dalton
    Member
    Posted 6 years ago #

    If I recall correctly, query posts and pagination don't work well together. I would use a plugin like CQS instead to control the number of posts that appear.

  5. freeriders
    Member
    Posted 6 years ago #

    ok thank you, it is like I have used query_posts('page_id=myidpage'); and it worked for that purpose

  6. drphil9001
    Member
    Posted 6 years ago #

    Did you find a solution to this problem? I have been implementing a similar theme and have been having similar problems. Although, I am no getting any navigation links at all.

    I am not sure that CQS will solve the problem since there is no selection is_page with it and our blog page is a Page with its own template.

  7. freeriders
    Member
    Posted 6 years ago #

    drphil9001

    yes I have used query_posts('page_id=myidpage'); and it worked for that purpose, if you have any problem, buzz me

  8. drphil9001
    Member
    Posted 6 years ago #

    freeriders,

    I believe that I found what is a bug when you have a template named the same as the actual Page title. My template name (in the PHP comments within the file) and the Page name were both "Blog". Once I changed the name of the template to "BlogTmpl" the navigation links magically appeared.

  9. freeriders
    Member
    Posted 6 years ago #

    ah ok, possible, I always name my template with the _tpl to be sure what they are at the first see.. I find it a good convention for naming

Topic Closed

This topic has been closed to new replies.

About this Topic