I'm quit new for wordpress development. Working with property management website with mobile API Development. Here need to filter the data's for based on conditions like greater than and less than & between range. For example need to filter and search the data's where price filter range and between and greater or less than bedrooms. Kindly help me to solve this issue.I've tried below example but not works to me http://192.168.0.88:8825/wp-json/wp/v2/properties?filter[meta_key]=property_bathrooms&filter[meta_value]=4&filter[meta_compare]=>=&filter[meta_key]=property_bedrooms&filter[meta_value]=5&filter[meta_compare]=>=&filter[meta_key]=property_price&filter[meta_value]=5,500&filter[meta_compare]=between
i create a custom page to display loop of cpt with custom field. I need to add a numberic pagination and i try with this code but not work. Functions.php function pagination_bar() { global $wp_query; $total_pages = $wp_query->max_num_pages; if ($total_pages > 1){ $current_page = max(1, get_query_var('paged')); echo paginate_links(array( 'base' => get_pagenum_link(1) . '%_%', 'format' => '/page/%#%', 'current' => $current_page, 'total' => $total_pages, )); } } custompage.php <!--Loop Salmi--> <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) …
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 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 …
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 bit of an odd situation. I have somehow solved it, but I'm trying to understand why my solution works. I'm using TheBuilt, a theme that uses Visual Composer. I have extended Visual Composer with a custom element that I use to display a custom posts page (the main loop is not in use on that page, nor is any other custom loop). In order to build a posts object, I create a new WP_Query object that looks …
Okay I am starting to wonder if it is even possible to do this! As I've found very little info on the matter online. This is a fresh WP install that I've been experimenting on so that I can work in a more simplified environment (rather than try to solve the full problem itself on my live client's website if that makes sense). I'm trying to display a total of 3 posts using query_posts(). I want the sticky posts to …
I have a custom post type, and in there I have a metabox with a dropdown. The dropdown is populated with the titles of posts from another custom post type. My metabox system works. I tried hardcoding the options and they save correctly. I can also pull the data from the custom post type to populate the dropdown. The issue lies within the save/loading of data. I've tried wp_query and get_posts, with their corresponding resets, but whenever I try to …
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($_POST['adicionar_cachorro'])){ wp_verify_nonce( $_POST['_wpnonce'], 'brg_add_dog'.$user_id ); $args = array( 'post_title' => $_POST['raca'] . " nascidos em " . $_POST['nascimento'] , 'post_content' => '', 'post_status' => 'publish', 'post_author' => $user_id, 'post_type' => 'ninhada', ); $post_id = wp_insert_post( $args ); if(isset($_FILES['foto_upload'])){ require_once( ABSPATH . 'wp-admin/includes/image.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/media.php' …
I've written a function that grabs all posts that are drafts and puts them as a dropdown in my toolbar for easy access to complete. This works just fine. The problem is that it seems to mess with my global $post object, specifically when called in my post/page editor. So if I'm in my post editor: http://example.com/wp-admin/post.php?post=147&action=edit 147 is the post I want to edit. But instead of showing the post corresponding to 147, it's showing the last draft in …
I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items instead of 6. Am I not resetting the loop correctly? <ul class="tabs"> <li class="tab-link current" data-tab="tab-1">Most Popular</li> <li class="tab-link" data-tab="tab-2">Recent</li> </ul> <div id="tab-1" class="tab-content current"> <div class="slider"> <div class="slide"> <?php query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&post_type=atls_video&posts_per_page=-1'); if (have_posts()) : while (have_posts()) : the_post();$count++; ?> <?php if ($count%6== 0) : ?> …
I'm trying to get posts from a custom posts using WP_Query. <ul> <?php $query1 = query_posts( array( 'posts_per_page' => -1, 'post_type' => array('specialties') )); if(have_posts()): while(have_posts()): the_post(); ?> <li> <!-- title from post type specialties --> <p><?php the_title(); ?></p> </li> <?php endwhile; endif; wp_reset_query(); ?> </ul> It's working just fine. Now I need to get posts from another custom post and show inside the already created loop. Now the code looks like this: <ul> <?php $query1 = query_posts( array( 'posts_per_page' …
So I'm working on a website for a client. Everything works fine except for the fact that the number of posts showing in the homepage of my development server is different from the number of posts showing in the production server. Here's my query: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 4 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="mini-post col-xs-12 col-md-6 col-lg-6"> <a href="<?php the_permalink(); ?>"> <h3><?php $title = …
I am using thesis in wordpress 4.1 i am trying to display related post by category with bellow function but when i go to the post detail page it throws internal server error.i have used same code in another website and the code is working good on that site and each word of code is same on both site i am stucked here i was increased the wordpress memory limit ,in php.ini file memory limit but that also not taking …
I have a custom query that goes looks like this: $temp = $wp_query; $wp_query = null; $args = array('posts_per_page' => 5, 'post_type' => 'gallery', 'post_status' => 'published', 'paged' => $paged); $wp_query = new WP_Query($args); if($wp_query->have_posts()): while($wp_query->have_posts()) : $wp_query->the_post(); if(get_post_format()) { $post_format = get_post_format(); } else { $post_format = 'standard'; } get_template_part('/templates/parts/format', $post_format); endwhile; endif; ?> Inside post format that I call with get_template_part('/templates/parts/format', $post_format); I have conditional is_page_template(). This conditional isn't working. But when I use regular WP_Query without resetting …
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 as $post): // variable must be called $post (IMPORTANT) ?> <?php setup_postdata($post); ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span><?php the_field('repeater_related_items'); ?></span> </li> <?php endforeach;?> </ul> <?php wp_reset_postdata(); ?> <?php endif;?> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Main Sidebar') ) : endif; ?> The problem is that when I add this to sidebar other widget doesn't …
so, heres the problem: i've created a category-template (category.php) with two query loops and the main loop (in which the content from the category should get looped in). if i now click on a category the template page shows but also the first two query loops get affected by it. everything is messed up. above is my template architecture. as you can see, i used the wp_reset_query function but this did not help. how do i make JUST THE MAIN …