I am guessing that this is what you want:
<?php
$type = 'post';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 2,
'caller_get_posts'=> 1,
'meta_key' => 'homepage',
'meta_value' => 'YES'
);
Thread Starter
neweb
(@neweb)
Hi vtxyzzy
I just posted your code to the page and its not displaying anything.
I have one post with the custom details as:
NAME: homepage Value: Yes
But nothing is showing on the page.
This is the code I put in:
<?php
$type = 'post';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 2,
'caller_get_posts'=> 1,
'meta_key' => 'homepage',
'meta_value' => 'YES'
); ?>
As a follow-up, I just noticed that the variable $paged is not set anywhere in the code you posted. If it is not set elsewhere, you should set it before using the code above. Here is code to put after the opening <?php
line:
if (!($paged = get_query_var('paged))) {
if (!($paged = get_query_var('page))) {
$paged = 1;
}
}
Thread Starter
neweb
(@neweb)
I put that code in like you said and I just got a blank page.
I tried it the following ways,
<?php
if (!($paged = get_query_var('paged))) {
if (!($paged = get_query_var('page))) {
$paged = 1;
}
}?>
<?php
$type = 'post';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 2,
'caller_get_posts'=> 1,
'meta_key' => 'homepage',
'meta_value' => 'YES'
); ?>
Then
<?php
if (!($paged = get_query_var('paged))) {
if (!($paged = get_query_var('page))) {
$paged = 1;
}
}
$type = 'post';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 2,
'caller_get_posts'=> 1,
'meta_key' => 'homepage',
'meta_value' => 'YES'
); ?>
Online after I took out the new code again did the page display (with no post)
My mistake, I left out a couple of quotes. Here is a corrected version:
if (!($paged = get_query_var('paged'))) {
if (!($paged = get_query_var('page'))) {
$paged = 1;
}
}
Thread Starter
neweb
(@neweb)
The page loaded with that code but its not showing the post’s with the custom fields:
NAME: homepage
Value: YES
This is the code I have
<?php
if (!($paged = get_query_var('paged'))) {
if (!($paged = get_query_var('page'))) {
$paged = 2;
}
}
$type = 'post';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 2,
'caller_get_posts'=> 1,
'meta_key' => 'homepage',
'meta_value' => 'YES'
);
?>
The page is displaying fine. Its just not showing the posts with the above custom fields.
This is the code for the complete page if this helps.
<?php /*
Template Name: First Page
*/
?>
<?php include('homeheader.php'); ?>
<div id="container">
<div id="content" role="main">
<?php if ( have_posts() ) while ( have_posts() ) : the_post();
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
<?php endwhile; ?>
<?php
if (!($paged = get_query_var('paged'))) {
if (!($paged = get_query_var('page'))) {
$paged = 2;
}
}
$type = 'post';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 2,
'caller_get_posts'=> 1,
'meta_key' => 'homepage',
'meta_value' => 'YES'
);
?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Make $paged = 1, not 2!!!!!
Thread Starter
neweb
(@neweb)
Did that and still the same result.
Still not showing the post with the custom field.
I don’t really want to give up on it because of the effort you have put in and I’m really grateful for the help with this.
I don’t know why, but your posts are not showing up when I view the link here: http://wordpress.org/support/topic/posts-added-to-pages?replies=5#post-1995639
I think the problem lies in the way that Twenty Ten and its derivatives are structured. get_template_part(‘loop’, ‘index’) will rerun the loop which used to be index.php. I think you may need to code your own loop, not call that one.
I need to see the full file where you are inserting the code. Please put the code in a pastebin and post a link to it here.
Thread Starter
neweb
(@neweb)
What files do I need to send over!!!
Is it loop.php and index.php ????
Start with the file that you have modified.
I am still not seeing your replies here. Use the Contact Me form at http://wordpress.mcdspot.com/contact-me/ to send me an email so we can continue this by mail.
Thread Starter
neweb
(@neweb)
Thanks for sorting this out for me Mac!