tags:

views:

60

answers:

1

I'm working with a script in which the postid of the page has been reset via a script include. How can I retrieve the actual true post id and reset its value once it has been changed via script?

Here is the script that I'm referring to. Somewhere in there, the postid is being reset so that the page's the_content() call is no longer pulling the current page being viewed.

I'm Ok with that, since that's what the script needs, however, I need to reset it back once this script has done its thing.

                <?php 

                    //$featpages = get_option('woo_slider_pages_landing');
                    $featpages = '579,584,537';
                    $featarr=split(",",$featpages);
                    $featarr = array_diff($featarr, array(""));

                    $i = 1;

                    foreach ( $featarr as $featured_tab ) {

                     query_posts('page_id=' . $featured_tab); while (have_posts()) : the_post();    

                ?>      

            <div class="featured-slide" id="slide-<?php echo $i; $i++; ?>" <?php if($i >=3 ){echo 'style="display:none"';} ?>>

                <div class="text">

                    <h2><?php if ( get_post_meta($post->ID, "page_desc", $single = true) <> "" ) { echo get_post_meta($post->ID, "page_desc", $single = true); } else { the_title(); } ?></h2>

                    <p><?php if ( get_post_meta($post->ID, "page_excerpt", $single = true) <> "" ) { echo get_post_meta($post->ID, "page_excerpt", $single = true); } else { the_excerpt(); } ?></p>

                        <?php if ( get_post_meta($post->ID, "link_text", $single = true) <> "" and get_post_meta($post->ID, "link_link", $single = true) <> "" ) { ?>

                        <p><a href="<?php echo get_post_meta($post->ID, "link_link", $single = true); ?>" title="<?php echo get_post_meta($post->ID, "link_text", $single = true); ?>"><?php echo get_post_meta($post->ID, "link_text", $single = true); ?></a></p>

                        <?php } ?>                                  

                </div><!-- /.text -->

                <?php if ( get_post_meta($post->ID, "image", $single = true) <> "" ) { ?>

                <div class="image">

                    <img src="<?php echo get_post_meta($post->ID, "image", $single = true); ?>" alt="<?php the_title(); ?>" class="featured" />

                </div><!-- /.image -->

                <?php } ?>

            </div><!-- /.featured-slide -->

            <?php endwhile; } //endforeach ?>
A: 

i'm assuming you meaning resetting the loop? if so you just add:

<? wp_reset_query(); ?>

at the bottom of your script (after endwhile)

Rob
Perfect! Thanks Rob.
Scott B
Rob, just for kicks, do you know where in the referenced script that postid get's changed?
Scott B
i'm sorry ask me that again? :S
Rob
The reason I'm having to use wp_reset_query is because the script example is resetting postid so that it no longer references the current page. I'm just trying to figure out where it actually does this.
Scott B
the query_posts function alters the loops default query, wp_reset_posts just does what it says on the tin, it resets it.
Rob