Static Page vs Blog Page
-
Hey Everyone,
I have the static homepage working fine.
Getting the “posts page” (the page that will show all of my posts) is causing a few problems for me.
Here is the code for my index.php file….
<?php get_header(); ?> <div id="contentWrap" class="group"> <div id="article"> <?php if (have_posts()) : while (have_posts()) : the_post();?> <?php if(is_page('blog') ) { ?> <a href="<?php the_permalink(); ?>"><h4 style="color:red;"><?php the_title(); ?></h4></a> <?php } else { ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php } ?> <?php endwhile; endif; wp_reset_query(); ?> <?php if(is_page() ) { ?> <!-- do nothing --> <?php } else { ?> <div class="feedback"> <?php comments_template( '', true ); ?> </div> <?php } ?> </div><!--article--> </div><!--contentWrap--> <?php get_footer(); ?> <?php get_footer(); ?>
What I want to happen is that when the page is my blog page is uses the <h4>’s and links to each post. I don’t want every page to self link to itself either if i had to use all <h1>’s.
In my reading options I set the posts page to blog. Oddly enough this if statement works if I don’t set that as my posts page, or if I replace it with a different page ( for instance is_page(‘contact’) ).
Is there a certain way to target the posts page?
Further frustration:
I’ve been able to get around this, by simply creating a blog page, but for some reason when I do this, if I am to set parent pages to a page the URL doesn’t include it.
For instance:
mysite.com/dog/husky/
When I make dog the parent page to husky I want the URL to show what is above but it only shows as:
mysite.com/husky/
That only happens when I do not select a certain page as my posts page. I am clueless as to why.
Here is my blog page:
<?php /* Template Name: Blog */ ?> <?php get_header(); ?> <div id="contentWrap" class="group"> <div id="article"> <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('posts_per_page=5' .'&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <?php the_excerpt(); ?> <?php endwhile; ?> <div class="alignleft"><?php next_posts_link('? Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries ?') ?></div> <?php $wp_query = null; $wp_query = $temp;?> </div><!--article--> </div><!--contentWrap--> <?php get_footer(); ?>
Any help is appreciated.
- The topic ‘Static Page vs Blog Page’ is closed to new replies.