The tag has no usage guidance.

learn more… | top users | synonyms

1
vote
0answers
101 views

wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query

I'm implementing a form for a frontend post with a shortcode. The form is processed in the same function, reloading the page: function adicionar_ninhada(){ $user_id = get_current_user_id(); if (isset(...
6
votes
1answer
95 views

How does reset_postdata restore the post of the main query loop?

How does reset_postdata works? The docs say: restore the global $post variable of the main query loop after a secondary query loop using new WP_Query But in the class, it takes the "current" ...
0
votes
0answers
27 views

Use two categories and remove for first data

So I find id for two post categories, and now I'm trying to write php code in content-single.php in acesspress lite. This is that I obtained: <article id="post-<?php the_category_ID(7); ?>" &...
0
votes
1answer
39 views

Optimizing the blog loop

I've got such post loop: <?php global $post; $post = $post_object; setup_postdata( $post ); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'post_type' ...
0
votes
1answer
45 views

numberposts not responding to wp_reset_postdata()

I am working on a loop where I want the content (from 2 separate categories) to be displayed like this: 1 large format post, 1 random product, 2 small format posts, 1 feature post ...repeat. In order ...
0
votes
0answers
59 views

Correct Way To Run Multiple Queries Sharing Some Base Data

I need to run three queries on the same page. The 'core' query is the same all three times - selecting posts in a particular taxonomy. I then need to run three queries on that subset looking for ...
0
votes
0answers
130 views

get_post_fields as an excerpt

I have a strange question, I have built my site and my loop etc. But on my sidebar I want to add a sort of random post display, but I don't want the entire post to display, I've had some difficulties ...
1
vote
1answer
37 views

Is resetting post data necessary with custom WP_CLI commands?

Is it strictly necessary to call wp_reset_postdata(); in a WP CLI command? I am doing it out of habit but just wondered if the $post object needed to be reset.
0
votes
2answers
78 views

Set post number to single posts

I have a function that I am using to number posts in a category. It is in my function.php and looks like this: function get_episode_number($postID){ $options = get_option('theme-opts'); $opts_cat = ...
0
votes
2answers
2k views

Custom WP_Query not working correctly

OK, So I have created a custom WP_Query that gets the post_type post and outputs it as a styled list. It works well and outputs the styled list but then underneath it displays all the posts again but ...
0
votes
2answers
131 views

Sort order in get_posts [closed]

I've created a custom template for a client. This is going to be a multilingual site setup on a Multisite install. As you can see under each category letter, the posts start out in alphabetical order ...
15
votes
1answer
16k views

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

Reading som stuff about query_reset_postdata and query_reset_query makes me confused... For example: 1) Is there any need to use both wp_reset_postdata and wp_reset_query together? ...
-1
votes
1answer
605 views

Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work

I am using ACF as related posts. I have the following code. <?php $post_objects = get_field('repeater_related_items'); if( $post_objects ): ?> <ul> <?php foreach( $post_objects ...
2
votes
1answer
371 views

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 ); $...
0
votes
1answer
114 views

Optimizing multiple WP_querys into one call?

I have finished building my website and noticed due to the structure it takes 3 seconds to load the data due to each WP_query bouncing between different post types. I was wondering if I put these into ...
1
vote
2answers
1k views

Why is wp_reset_postdata() restarting the loop from the first post?

I've used the second-last example showed here: https://github.com/scribu/wp-posts-to-posts/wiki/each_connected The only difference is that I've put the_title after echoing the connected posts. So my ...
4
votes
1answer
3k views

Is it necessary to reset the query after using get_posts()?

Is it necessary to reset the query after using get_posts() ? I have been looking at this page and I don't see any reference to get_posts() ... I can't make it out for sure from this page either. I ...
1
vote
1answer
895 views

Is there any need to use both wp_reset_postdata and wp_reset_query together?

Is there any need to use both wp_reset_postdata() and wp_reset_query() together? Is it a case that I would pick one of the two functions; is there any point in doing this after a query : ...
0
votes
1answer
545 views

How to reset post data properly

I have this piece of code that I am calling within the loop to get image metadata ( title/caption and description ). It works fine but it only works for the first post in the loop. So I assume it ...