only delete post within query / for each statement (front end)

You should pass in the id of the post you want to delete as an argument of the delete_post() function rather than relying on obtaining it via global $post within the function itself: <?php echo delete_post($section->ID); ?> Then in your delete_post() function you can use the passed-in argument like so: function delete_post($sectionid){ $deletepostlink= add_query_arg( ‘frontend’, … Read more

Getting back to ajax search results from a page

I solved this using the HistoryAPI. Since my ajax returns objects that has response, html and query, I pushed the html results of the search to the history state with window.history.pushState( date_out.html, null, null); where data_out is the object returned from the ajax call. Then I added a button on the single advert page that … Read more

Display only past events on that page using Visual Composer Grid Bulider

Finally i got answer. post_type=event&meta_query%5B0%5D%5Bkey%5D=date_short_order&‌​meta_query%5B0%5D%5B‌​value%5D=$today&‌​meta_query%5B0%5D%5B‌​compare%5D=%3C&meta_‌​query%5B0%5D%5Btype%‌​5D=DATE post_type=event&meta_query%5B0%5D%5Bkey%5D=date_short_order&‌​meta_query%5B0%5D%5B‌​value%5D=$today&‌​meta_query%5B0%5D%5B‌​compare%5D=%3C&meta_‌​query%5B0%5D%5Btype%‌​5D=DATE

A loop with all articles with certain text strings in tags

Based on @birgire’s always-useful comments, I did write a workaround for you. What I’m doing is to first find the terms that match the search string. Then, based on the found terms I will do a query in those. function wpse_posts_by_tagname( $string ) { // Let’s find every tag that has ‘coffee’ in it’s name … Read more

MySQL variable in query

See the documentation for $wpdb->prepare(). You need to pass a String, but you’re typing set @csum directly in the parameter. Your code should look like this: if ( is_user_logged_in() ) { $user = wp_get_current_user(); $balance = $wpdb->query( $wpdb->prepare( “SET @csum := (SELECT current_balance FROM exp_ten WHERE tenant_number=%d); SELECT tenant_number, transaction_amount, (@csum := @csum + transaction_amount) … Read more

Query all published post AND attachment with specific mime type

First of all if any is used for post_type field there can not be any other value given in array like in the question. Below is the modified args $args = [ ‘post_type’ => array_values(get_post_types([‘public’ => true])), ‘post_status’ => [‘publish’, ‘inherit’], ‘posts_per_page’ => 10 ]; Use posts_where filter add_filter(‘posts_where’, ‘add_search_mime_types’); $query = new WP_Query( $args … Read more

Custom filter in admin edit custom post type responding with invalid post type?

I am also get the issue same as you and finally I got the solution. We have to add $query->is_main_query() in IF CONDITION. if( ‘trip’ == $type && is_admin() && $pagenow==’edit.php’ && isset($_GET[‘tripstatus’]) && $_GET[‘tripstatus’] != ” && $query->is_main_query()) { $value = $_GET[‘tripstatus’]; $query->query_vars[‘meta_key’] = ‘trip_status’; $query->query_vars[‘meta_value’] = $value; } I hope it will help … Read more