Remove divs and spans from post content

Im not sure what you are actually doing here but I think you are looking to create a block of code from the post content then strip unnecessary tags. I would use strip tags: https://www.w3schools.com/php/func_string_strip_tags.asp <?php require “wp-config.php”; // Post Types to include $args = array( ‘posts_per_page’ => ’50’, ‘post_type’ => array( ‘product’, ‘product-variation’ ) … Read more

WP_Query and DES sort for Custom Taxonomy based upon a meta field?

Nothing. You shouldn’t need to set the post type. Your taxonomy archive is presumably already querying the correct post type. function customize_customtaxonomy_archive_display ( $query ) { if ( $query->is_tax( ‘country’ ) ) { $query->set( ‘meta_key’, ‘start_date’ ); $query->set( ‘orderby’, ‘meta_value_num’ ); $query->set( ‘order’, ‘ASC’ ); } } Note: $query->is_main_query() is redundant when checking $query->is_tax(), because … Read more

How to hook the pre_get_posts filter via ajax call

You can apply a custom filter on your WP_Query that is on your ajax callback function like this: $my_query = apply_filters(‘my_plugin_pre_get_posts’, (new WP_Query($args))); Now you can use your existing pre_get_posts function for ajax calls also, add_action(‘pre_get_posts’, ‘myplugin_filter_posts’); // For All WP_Query instances add_filter(‘my_plugin_pre_get_posts’, ‘myplugin_filter_posts’); // For ajax function myplugin_filter_posts($query) { if (defined(‘DOING_AJAX’) && DOING_AJAX) { … Read more

Adding arguments to WooCommerce Product Loop using AJAX

Figured this out now. Instead of using $wp_query->set(), I instead set arguments, and then ran the woocommerce loop. This is the final code I used. add_action(‘wp_ajax_listFilteredProducts’, ‘listFilteredProducts’); add_action(‘wp_ajax_nopriv_listFilteredProducts’, ‘listFilteredProducts’); function listFilteredProducts($wp_query) { if(isset($_GET[‘formData’])) { $value = $_GET[‘formData’]; } // If no price input, but tags have been input if ($value[‘priceRange’] == 0 && $value[‘tags’] != … Read more

Weird query with get_posts and WP_Query

I just tried to replicate your code and the only issue I came up with is in one of the arguments to your CPT setup. You have “capability_type” => “comunicado”, But this prevented the CPT working correctly for me. I don’t think this argument should be referring to itself. I replaced it with ‘post’ to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)