<?php wp_reset_postdata(); ?>
<?php wp_reset_query(); ?>
<?php rewind_posts(); ?>
So in short I want it to move 5 posts back every 5 posts. I can use if for this but I cant find value that describes what post number is currently displayed. I have tried $this->current_post and it echoes posts numbers with no problems. But if I try to change this value for example:
$rewind_posts_bol = true
if ($rewind_posts_bol){
$this->current_post = 3;
rewind_posts_bol = false;
}
If I understand it correctly then this code should do something like offset 3 but it isnt working. So is there any way to rewind posts by desired number?
Thanks in forward
]]>I have each activity as a child of the main activities landing page. The landing page template then grabs the content, truncates it, and creates a link for each of these child pages. That much works… BUT how do I control the order in which they appear??????? I’ve tried changing the “order” number and the “published on” dates in word press for each page… but this has not worked… Below is my code. Can anyone tell me how to edit this to give me the ability to sort my output… THANK YOU!!!!!
get_header(); ?>
<div id="pageContent">
<table class="pageContentTable">
<tr class="spacing">
</tr>
<tr class="regularRow">
<td class="sidebar" valign="top" >
<div class="sidebar_wrapper">
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar('primary-sidebar') ) : ?>
<?php endif; ?>
</div>
</td>
<td class="main_page_content" valign="top">
<div id="ContentInset">
<!---Places Page Title---->
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<h1><?php the_title(); ?></h1>
<?php endwhile; endif; ?>
<!---Places Page Content---->
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php
$current_page = $post->ID;
$querystr = "
SELECT * from $wpdb->posts
WHERE post_type = 'page'
AND post_parent = $current_page
";
$child_pages = $wpdb->get_results($querystr, OBJECT);
if ($child_pages):
foreach($child_pages as $post) :
setup_postdata($post); ?>
<table class="activityList">
<tr>
<td class="activity_logo_cell">
<a href="<?php the_permalink();?>"><?php the_post_thumbnail('Activity_Logo_Small');?></a>
</td>
<td class="activity_content_cell">
<h2><?php the_title(); ?></h2>
<?php
$thecontent = $post->post_content;
$getlength = mb_strlen($thecontent);
$thelength = 350;
echo substr(strip_tags($thecontent), 0, $thelength);
if ($getlength > $thelength) echo "…";
?>
<a href="<?php the_permalink();?>"><?php _e('[Read More]');?></a>
</td>
</tr>
</table>
<h4></h4>
<?php endforeach; ?>
<?php else : ?>
No additional information about activities is currently available. Check back soon!
<?php endif; ?>
<?php rewind_posts(); ?>
</div>
</td>
</tr>
</table>
</div>
</div> <!---Main Content Wrapper---->
<?php get_footer(); ?>
]]>[Code moderated as per the Forum Rules. Please use the pastebin]
]]>Here is the code for the page:
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<h2>Not Found</h2>
<p>Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>
<?php if (is_page('15')) {?>
<h3>Testimonials</h3>
<?php rewind_posts(); ?>
<?php query_posts('category_name=testimonials'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php $testimonial_author = get_post_meta($post->ID, 'testimonial_author', $single = true); ?>
<div class="testimonial_container">
<p class="testimonial">
“<?php the_content_rss(); ?>”
</p>
<?php // if there's a thumbnail
if($testimonial_author !== '') { ?>
<p class="testimonial_author">
— <?php echo $testimonial_author; ?>
</p>
<?php } // end if statement
// if there's not a thumbnail
else { echo ''; } ?>
</div>
<?php endwhile; ?>
<?php } ?>
</div>
<?php global $post;
$sidebar_id = $post->ID;
get_sidebar('sidebar-'.$sidebar_id);
?>
<?php get_footer(); ?>
I would really appreciate any help with this… I’m pulling my hair out!
Thanks,
Kevin
Since upgrading to 2.8.x, it seems that the mini loop won’t rewind, so the last listed event’s the_title
overwrites whatever page or post you’re looking at (amongst other items on the page).
Either something is broken with WordPress, or the way I’m calling these items.
Here’s the code, which worked under 2.7.x and earlier:
<ul>
<?php
$future_events = new WP_Query('category_name=Calendar&post_status=future&order=ASC&showposts=5');
while ($future_events->have_posts()) : $future_events->the_post();
$do_not_duplicate = $post->ID;
?>
<li>
<span class="date">
<?php the_time('M. j | g:i a'); ?>
</span><br />
<a href="<?php the_permalink() ?>">
<?php// the_title(); ?>
</a>
</li>
<?php endwhile; ?><?php rewind_posts(); ?>
</ul>
Any thoughts/suggestions?
Thanks!
]]>I’m trying to use a loop and query_posts to grab content from a certain page, then rewind_posts to display the rest of the content normally.
It’s an extra section in my header.php:
<?php if (have_posts()) : while (have_posts()) : the_post();
$values = get_post_custom_values("Page Description");
endwhile; endif; ?>
<?php if ($values[0]) : echo $values[0];
else :
query_posts('pagename=default-description');
if (have_posts()) : while (have_posts()) : the_post();
the_content();
endwhile; endif;
endif; rewind_posts(); ?>
But rewind_posts isn’t actually doing anything. The if statement works as expected, but if I’m on a page that doesn’t have anything in Page Description, it calls the default-description page where it’s supposed to AND for every other loop on the page.
Why? I thought rewind_posts was supposed to reset the WP_query…
Any help is greatly, greatly appreciated.
]]>What I wanted was to have multiple category-specific post loops on one page (index.php, say). I put this in each loop:
<?php if (in_category('1')) continue;?>
And after each endwhile
, I have this (is it necessary? It doesn’t seem to make a difference.):
rewind_posts();
This works, sort of. What it ended up doing is excluding everything in category one instead, or simply including posts in all categories.
To get a post loop to show only posts in category 1, I had to use:
<?php if (in_category('2') || in_category('3')) continue;?>
or
<?php if (!in_category('1')) continue;?>
to exclude all other categories.
Isn’t in_category() supposed to specify which categories to include rather than exclude?
Thanks.
]]>Then that has subpages such as this page: https://mguthrie.net/portfolio/photography
Now, on the main Portfolio page, the h2 displays the title as “portfolio” which is correct.
But on the photography, the h2 displays the title as “photography”. I know that it’s just displaying a title there, but I would rather it still say Portfolio.
I would rather not have to hardcode the headers in. Can anyone tell me if there is a way to tell subpages to display the parent header but not effect the parent pages?
]]>