Hi there, I currently have a section on the bottom of my homepage that shows a post title, image and brief excerpt for three posts in a category. These are shown as three columns under my slider.
I am using this code:
<!--Index Articles-->
<div id="index_articles">
<ul>
<?php query_posts('category_name=services&showposts=3'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<img src="<?php echo get_post_meta($post->ID, "serv", true);?>" class="articletitlepic" alt="" align="left" />
<h3 class="myclass typeface-js"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
</li>
<?php endwhile; else: ?>
<li>
<h2>Woops...</h2>
<p>Sorry, no posts we're found.</p>
</li>
<?php endif; ?>
</ul>
</div>
<!--End Index Articles-->
I want to create the same section, but use 3 PAGES instead of posts. I have searched the codex but can not find how to show just the information I need from the pages or how to say which pages I want.
Any chance I have just missed something and it is as easy as changing post to pages (I have tried this but maybe not in the right way)
Thanks
Is this more complicated than I think it is? I thought displaying information from pages would be easy?
I thought it was just me missing the obvious.
Can anyone point me in the right direction on the codex? i have searched if for answers but found none.
Thanks
rguy84
February 9, 2011, 3:42pm
3
On Pages page, it has a section for including pages . That may help
The codex tells me it is possible, but then only provides a link to a plugin.
rguy84
February 9, 2011, 4:05pm
5
yeah, you need to use the plugin to do it…
Really? I have to use a plugin to display content from a page on the homepage of the site?
Couldnt i use something like this:
query_posts( 'pagename=contact' );
And then get the page title, image and excerpt?
This seems like I am getting closer, but still not getting the page reults I want?
<?php query_posts('page_name=commercial-services&community-development&domestic'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<img src="<?php echo get_post_meta($post->ID, "serv", true);?>" class="articletitlepic" alt="" align="left" />
<h3 class="myclass typeface-js"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
</li>
<?php endwhile; else: ?>
I changed the top code to:
<?php query_posts('post_type=page&pagename=services/domestic'); ?>
I get the page I want, but I want to grab 2 more pages.
Can I use an array in some way?
Now trying an array:
<?php $args = array(
'post_type' => 'page',
'pagename' => array('domestic', 'commercial-services', 'community-development')
);
query_posts( $args ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<img src="<?php echo get_post_meta($post->ID, "serv", true);?>" class="articletitlepic" alt="" align="left" />
<h3 class="myclass typeface-js"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
But still no luck?
rguy84
February 9, 2011, 5:31pm
10
Why not just put the contact stuff in the homepage file?
Contact stuff? Not sure what you are referring too?