?
Solved

Need Help Configuring Wordpress With Static Front Page and Blog Posts Beneath Page

Posted on 2011-10-27
21
Medium Priority
?
277 Views
Last Modified: 2012-05-12
I am working with the TwentyTen theme in WordPress (http://agape-academy.com). I have configured a static front page and want to add the necessary code, so blog posts show up beneath the front page, rather than on a static  page for blog posts.
0
Comment
Question by:tamray_tech
  • 12
  • 9
21 Comments
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 2000 total points
ID: 37042558
You're talking about creating a template for a page of posts:

http://codex.wordpress.org/Pages#A_Page_of_Posts
0
 

Author Comment

by:tamray_tech
ID: 37042587
I am if this page can appear under my static front page. Looked over the link quick. Is that how this solution will work? If so, I will work on setting it up in the morning and let you know my results.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37042607
Basically, yes. What you need to do is set up a page template so you can add your content and then hard-code the WordPress Loop below the content to get the posts to show up.  The link shows you the basics on how to get there.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tamray_tech
ID: 37044661
Couple questions: From the instructions, I should I create a php page with the template header in it and "pageofposts.php" should show up as a template under "Appearance, Editor" of the current theme, on the right column. I see the file in my dashboard, but not via Wordpress. Permissions seem to eb the same for my new template as the others already there.

Secondly, I am not clear about your comment "What you need to do is set up a page template so you can add your content and then hard-code the WordPress Loop below the content to get the posts to show up"

Can you provide specifics?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37047399
If you look at the code of "A Page of Posts" you'll notice it is missing:

<?php the_post(); ?>

which is the piece of code that calls back the Page content as entered into the Editor.  So all my comment was is a reminder to make sure you put that in above the Loop code so you can add "static" content.  If you just copy the code without alteration, it's the same as setting the home page to "Recent Posts"
0
 

Author Comment

by:tamray_tech
ID: 37047962
Your way ahead of my pay scale. I now have the template showing up under Appearance, Editor, but do not see anything in pageofposts with a loop statement. I have very limited knowledge working with php, so I need specifics to follow.
0
 

Author Comment

by:tamray_tech
ID: 37048008
I found some documentation on it. Is this the correct place to add it to pageofposts?

 $wp_query = new WP_Query($args);
<?php the_post(); ?>
  if( have_posts() ) :
            while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
0
 

Author Comment

by:tamray_tech
ID: 37048061
I believe I have the template set up right, but not sure what else I need to do to get the blog posts to show up under the static front page.
0
 

Author Comment

by:tamray_tech
ID: 37054634
bump
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37054931
>> Your way ahead of my pay scale.

Then you might need to buy an hour or two of developer time to help you get over the top.  Making a new template and adding code to it is described in the link I sent earlier:

http://codex.wordpress.org/Pages#A_Page_of_Posts

>> I found some documentation on it. Is this the correct place to add it to pageofposts?

No, that code you reference is the Loop.  It goes into the page template.  If you look at the link above, you will see a nearly complete page template that pulls in posts.

0
 

Author Comment

by:tamray_tech
ID: 37055887
Why not just show me what to do rather than tell me I should know, which obviously I do not. I pay for this service so I don;t have to be a pro in every field and can get quick answers to things I rarely deal with. I pasted this line above what I resumed was the loop: <?php the_post(); ?>. If it is incorrect please demonstrate where it should go and how I bring the page up under my front static page, so we don;t have to trade 6 more email while I try to figure it out.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37057124
You pay to access the service (which pays for bandwidth, etc) but I'm a volunteer and I prefer to answer questions in a teaching manner.  I'm trying to teach you the concepts by getting you to work through the examples provided and answering questions from you as you get stuck.  I'm sorry if that isn't to your liking but just dumping code is neither fun nor productive for me.

Please paste your compete custom page template so I can check it.  
0
 

Author Comment

by:tamray_tech
ID: 37057737
Thank you for explaining things to me. As an end user, I have no idea how people are compensated for their help. I assumed at least some of the fees collected somehow benefited the experts. My mistake. I am assuming I have a complete misunderstanding of instructions thus far, as I interpreted them to mean I should paste the line  <?php the_post();?> above the (What I believed to be) loop statement of the pageofposts.php template. Here is my template:

<?php
/*
Template Name: PageOfPosts
*/

get_header(); ?>

<div id="content" class="narrowcolumn">

<?php
if (is_page() ) {
$category = get_post_meta($posts[0]->ID, 'category', true);
}
if ($category) {
  $cat = get_cat_ID($category);
  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  $post_per_page = 4; // -1 shows all posts
  $do_not_show_stickies = 1; // 0 to show stickies
  $args=array(
    'category__in' => array($cat),
    'orderby' => 'date',
    'order' => 'DESC',
    'paged' => $paged,
    'posts_per_page' => $post_per_page,
    'caller_get_posts' => $do_not_show_stickies
  );
  $temp = $wp_query;  // assign orginal query to temp variable for later use  
  $wp_query = null;
  $wp_query = new WP_Query($args);
<?php the_post(); ?>
  if( have_posts() ) :
            while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
          <div <?php post_class() ?> 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 »'); ?>
        </div>
        <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
      </div>
    <?php endwhile; ?>
    <div class="navigation">
      <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
      <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
    </div>
  <?php else : ?>

            <h2 class="center">Not Found</h2>
            <p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php get_search_form(); ?>

      <?php endif;
      
      $wp_query = $temp;  //reset back to original query
      
}  // if ($category)
?>

      </div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37057790
Thanks for this.  Give me a few hours to shoehorn this in around my paying job and test it on a local wordpress installation.  I'll reply with code and explanation.

>> I assumed at least some of the fees collected somehow benefited the experts.

Everybody does.  We earn t-shirts when we hit milestones but 6,000,000 points in I have enough shirts and I do this because I enjoy it.

I know, I'm insane :)
0
 

Author Comment

by:tamray_tech
ID: 37070070
Any progress with this?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37070165
Sorry, real life and real job are conspiring to limit EE time.  I should be able to get to it later today.  
0
 

Author Comment

by:tamray_tech
ID: 37070175
No problem
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 2000 total points
ID: 37074616
Try it this way instead:

 
<?php
/*
Template Name: PageOfPosts
*/

get_header(); ?>

<div>


<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
  	  <div <?php post_class() ?>>
		<div class="entry">
			<?php the_content(); ?>
		</div>
	<?php edit_post_link('Edit this entry.', '<span>', '</span>'); ?>
	</div>

  <?php endwhile; endif; ?>


<?php $temp_query = clone $wp_query; ?>

  <h3 class="sub-title">Featured <?php the_title(); ?></h3>

<?php query_posts('posts_per_page=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
  	  if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
	<div <?php post_class() ?>>
		<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
		<div class="entry">
			<?php the_excerpt();?>
			<a class="more-link" href="<?php the_permalink(); ?>">Continue Reading</a>
		</div>
	</div>

  <?php endwhile; endif; ?>

 <?php $wp_query = clone $temp_query; ?>

</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

Open in new window

0
 

Author Comment

by:tamray_tech
ID: 37078607
I seems to me the template 'pageofposts" is working, but I am not sure how to call it, so it is below my static front page.  I have included a screen shot of the page I created using the pageofposts template. You can view what I have at http://agape-academy.com


Screenshot.png
0
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 2000 total points
ID: 37078707
When you create the page in the editor, look to the right side and select the Page of Posts page template.  Then publish and set it as your site's front page via Settings | Reading
0
 

Author Closing Comment

by:tamray_tech
ID: 37078916
jason1178 provided a complete solution to my question.

Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question