I added my data base on my wordpress server. Now I want people on my page to have the option to enter a LionID and then be given the data of that lion. I would like to display the data in a way as shown in the 2nd photo. Furthermore, this dataset also has a URL link of the image of each lion. I would also like to display these next to the values given. Hopefully this is possible. Thanks …
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 but "M" and "O" are all out of whack. If you click through onto those categories, using the alphabet bar at the top, those posts are in alphabetical order. Both pages are using the same code, so I've no idea what I'm doing wrong. …
I'm hooking into 'edit_form_after_editor' add_action('edit_form_after_editor', 'make_the_button_to_generate_a_report_number'); function make_the_button_to_generate_a_report_number($post) { Check that I am dealing with a custom post type of 'publications' if ($post->post_type != 'publications') return; Create a number of arguments that I then run in a WP_Query $new_query = new WP_Query($report_number_args); use that data to do stuff... Then I want to reset $post back to how it was, so I run wp_reset_postdata(); But $post stays on the last item I had received from my new WP_Query(). What am I …
i have this query add_action('edit_form_after_title', 'get_books'); function get_books($main_post){ global $post; $list = ''; // print the current post (everything is still fine here) print_r($post); $args = array( 'posts_per_page' => '20', 'post_type' => array('books') ); $my_query = new WP_Query($args); if ($my_query->have_posts()) { $list .= '<select name="books_list">'; while ($my_query->have_posts()) { $my_query->the_post(); // my code $list .= '<option value="'.get_the_ID().'">'.get_the_title().'</option>'; } $list .= '</select>'; wp_reset_postdata(); } // i try another methods but still same problem. wp_reset_postdata(); $my_query->reset_postdata(); wp_reset_query(); // here print the last post …
I love ACF, its great for developers and it seems to have so much support. BUT... Why is reset_rows() not in the documentation? I created a function that can delete repeater rows at different times in the code. I was using the rows loop each time expecting it to start at index 0 (or 1 in acf's crazy way). But each loop started where the previous one left off. This gave me grief for quite a while. I have only …
Edit - I already tried wp_reset_query() it doesn't work, the first loop executes as intended but the second loop just jumps to the else and I get not working I am using 2 custom WP_Query loops in one page, the first is to get posts from a certain category, and the second is just getting the posts by dates, here's the code <?php $args = array( 'post_type' => 'post', 'post_status' => 'any', 'category' => 3, 'posts_per_page' => 4); $query_var= new …
In custom post meta I have executed a custom query to get custom meta but when I tried to return to the main $post query, its printing the secondary loop.Where is my custom query and I have reset it by wp_reset_postdata().But no result. $custom_fields = get_posts( array( 'post_type' => 'custom_field', 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_key' => 'associate', 'meta_value' => 'form' ) ); foreach ($custom_fields as $post) { setup_postdata($post); var_dump(get_the_ID()); } wp_reset_postdata(); wp_reset_query();
I have installed a plugin following wp plugin install ... CLI command and then activate through CLI command its working properly. But problem is that when I deactivate then delete the plugin the table which is related to this plugin is still in my database. Is there any way to delete the unused unnecessary tables from wp database?
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
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 you should never use wp_reset_query because you shouldn't use query_posts!? In the WP Codex it states that you should use wp_reset_query() after a custom loop …
Have 2 plugins which power some extra woocommerce custom options in WP. Both hook to plugins_loaded. The 1st plugin is not resetting to the original post data by the looks of things. One plugin is a sample drop down with the post metaboxes. The plugin queries the db using WP_Query to output a select options box. I run wp_reset_postdata() after. The second plugin is a different select box which is not pulling with the correct post id so the meta …
I have to use parent posts as categories. So I'm checking if current post has childs and show them or else show te content. I'm trying like this (in single-practice.php): <?php $has_children = false; $children = get_children( array( 'post_parent' => get_the_ID() ) ); wp_reset_postdata(); if ( ! empty($children) ) { $has_children = true; } if ($has_children) { $args = array( 'post_type' => 'practice', 'orderby' => 'menu_order', 'post_parent' => get_the_ID(), 'paged' => false ); $query = new WP_Query( $args ); /* …
I have a main query, in which I set up a new custom query to retrieve posts (think about 'related posts' or something like that). Than in each of those posts, I'm setting an other custom query, load data from a single post, then I should find a way to reset postdata to the first custom query. How can I do that? I tried wp_reset_postdata(), but that resets to main query. A simplified code would look thus: while ( have_posts() …
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.
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 achieving this so if you have any alternative methods you wish to share, please let me know :) What I want to achieve at the moment is shorten the content shown, I know you can do this with excerpt() …
I've searched for this in the Q&A but I was unable to find it. When I read answers throughout the site I see wp_reset_postdata() placed in multiple areas with the have_posts() conditional and outside the conditional all together. When I read the documentation on wp_reset_postdata() all it states is: After looping through a separate query, this function restores the $post global to the current post in the main query. with a snippet of: <?php // example args $args = array( …
I use the code below, added to a template, to display random posts. <ul> <?php $posts = get_posts('orderby=rand&numberposts=5'); foreach($posts as $post) { ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php } ?> </ul> Do I need to reset, presumably by changing <?php } ?> to <?php } wp_reset_postdata(); ?> And does the need to reset depend on whether this code-block is before or after other loops/queries in the template?