Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?

Starting with an example makes more sense, so here’s an example function: function seo_meta_tags() { global $post; if( is_singular() ) { setup_postdata( $post ); $description = str_replace( ‘… <a class=”read-more” href=”‘ . get_permalink() . ‘”>Cont. reading &rarr;</a>’, ‘…’, get_the_excerpt() ); wp_reset_postdata(); echo ‘<meta itemprop=”description” name=”description” content=”‘ . $description . ‘”>’; } } NOTE: The code … Read more

ACF Repeater loops and resets – where is the reset_rows() documentation? [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for WordPress Development Stack Exchange. Closed 2 years ago. Improve this question I love ACF, its great for developers and it seems to have so much support. BUT… Why is reset_rows() not in … Read more

When should you use wp_reset_postdata vs wp_reset_query?

Seems like half the tutorials in the Codex use wp_reset_postdata() and half use wp_reset_query(). What’s the deal? Maybe Use both of them? What about rewind_posts()? I am asking for an answer based on facts, not on opinions. 1 Answer 1 wp_reset_postdata() resets the value of the global $post variable to the post property of the … Read more

Why should i use wp_reset_postdata()?

I am not able to understand the use of wp_reset_postdata. what could go wrong if i am not using it? https://codex.wordpress.org/Function_Reference/wp_reset_postdata Here in documentation what is main query and secondary query? Thanks 1 Answer 1 WordPress uses global $post variable. This way you don’t have to pass post nor post_ID as param for functions. So … Read more

wp_reset_postdata() or wp_reset_query() after a custom loop?

Reading some stuff about query_reset_postdata and query_reset_query makes me confused. For example: Is there any need to use both wp_reset_postdata and wp_reset_query together? http://www.poststat.us/properly-reset-wordpress-query/ Above states that you should only use query_reset_postdata() when using “separate queries”. In example2 there’s a comment: WP_Query( $args ) = wp_reset_postdata(); AND query_posts ( $args ) = wp_reset_query(); And really … Read more