add_query_arg() XSS Vulnerability

Unless I’m missing something that is staring me in the face, you aren’t using add_query_arg() or remove_query_arg(); since those are the only functions affected by this particular exploit you should be safe. Your code does use the query_vars filter and get_query_var() but neither of those are effected by the exploit you’ve referenced. Otherwise your code … Read more

Categories and products in random order

as suggested by kaiser, my last working edit as solution: ok, inspired by @s_ha_dum answer i manged to get a solution: //this 1. part is out of the woocommerce-template.php and part of the woocommerce_product_subcategories() $product_cat = get_term_by( ‘slug’, $product_cat_slug, ‘product_cat’ ); $product_category_parent = $product_cat->term_id; $pcat_args = array( ‘child_of’ => $product_category_parent, ‘hide_empty’ => 1, ‘hierarchical’ => … Read more

Get a user’s most recent post title

You just set the ‘author’ parameter in a WP_Query query or get_posts (which accepts the same parameters): $recent = get_posts(array( ‘author’=>1, ‘orderby’=>’date’, ‘order’=>’desc’, ‘numberposts’=>1 )); if( $recent ){ $title = get_the_title($recent[0]->ID); }else{ //No published posts } (Note the ‘orderby’ and ‘order’ here are redundant because they are set to their default values, but you get … Read more

Custom $wpdb Query for Custom Post Type by Category

Don’t use $wpdb, use wp_query. Not only will your code be leaner and quicker, you’ll avoid issues like this. Unless you’re doing something with custom tables or seriously in-depth SQL, there’s no reason to do direct SQL calls on $wpdb. So, to answer your question – rewrite it from the ground up using wp_query, see … Read more

How to display lastest post date in the homepage?

I would save an option on post save: add_action( ‘save_post’, function($id,$p) { if ( (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) || (defined(‘DOING_AJAX’) && DOING_AJAX) || ($p->post_status === ‘auto-draft’) ) { return; } update_option(‘_last_site_update’,$p->post_date); }, 1,2 ); And retrieve it with a variant of the function provided by @G-M : function my_last_updated( $format=”” ) { $last = get_option(‘_last_site_update’); if … Read more

How to get my loop to pull posts into three columns

First of all, never use query_posts Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. … Read more

Query & Sort Comments by custom comment meta

Unfortunately it’s unsupported by the applicable WordPress functions for querying comments, which is primarily due to(i feel) not enough people(or anyone) yet asking for it. I want to highlight a couple of core files here to help understand the issue. First up comments-template.php, the comment_template function, it’s this function that queries for comments and then … Read more

Search Terms – Querying on either description__like OR name__like in the same Term Query?

I don’t see any options for WordPress to search terms by both of name & description. So i combined 2 queries like @StephanieQ but maybe more simple way, checkout my ajax response below: public function ajax_project_terms_search() { $results = array(); $search_query = sanitize_text_field($_GET[‘q’]); $withname = intval($_GET[‘withname’]); $search_keys = array(‘name__like’, ‘description__like’); $exclude = array(); foreach ($search_keys … Read more

query multiple taxonomy and show post count

I’m sure that a custom sql query would work much better but here is an option using the WordPress Tools available //first get all categories $categories = get_terms( ‘category’, array( ‘orderby’ => ‘count’, )); //then create an array for easier processing foreach ( $categories as $cat ) { $slugs[] = $cat->slug; $counts[$cat->slug][‘count’] = $cat->count; } … Read more

Very slow query

To check if the query itself is slow or anything else slows it down, try running your query directly in the database, and have a look at how long it takes there. <?php echo $GLOBALS[‘wp_query’]->request; ?> This shows you the latest Query that WordPress ran in your database. If the query is really slow in … Read more

techhipbettruvabetnorabahisbahis forumutaraftarium24edusedusedusedueduedusedueduedusedu