Remove Dimension from wp_get_attachment_image

Your arguments for both wp_get_attachment_image_url() and wp_get_attachment_image() are in the wrong order – check the linked documentation for details. Additionally, wp_get_attachment_image_url() returns a URL – not an actual image element. Removing the width and height attributes from <img> elements is inadvisable: if the layout of the page is in any way influenced by the size … Read more

Is there any action filter/hook for validating a custom field before publishing the post?

At the beginning of wp_insert_post, the function that saves/updates a post, there is a filter called wp_insert_post_empty_content. By default this filter checks whether the title, editor, and excerpt fields are all empty, in which case the save process will be halted. However, since all the fields to be saved are passed to this filter, you … Read more

Filter by one custom field, order by another?

You could use the query to filter the content as you intended by using the ‘meta_query’ with filtering options, and for the order part, just add/modify the following parameters: ‘orderby’ => ‘meta_value’ ‘meta_key’ => ‘location_level1_value’ ‘order’ => ‘ASC’ $wp_query = new WP_Query( array ( ‘post_type’ => ‘listing’, ‘posts_per_page’ => ‘9’, ‘post_status’ => ‘publish’, ‘meta_query’ => … Read more

How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?

A GROUP BY statement can group your posts after the JOIN. For WordPress you can use the posts_groupby filter. add_filter( ‘posts_groupby’, ‘my_post_limits’ ); function my_post_limits($groupby) { global $pagenow, $wpdb; if ( is_admin() && $pagenow == ‘edit.php’ && $_GET[‘post_type’]==’listings’ && $_GET[‘s’] != ” ) { $groupby = “$wpdb->posts.ID”; } return $groupby; }

Is ACF being a honey trap? [closed]

Few months ago @tom-j-nowell (one of the mods here) wrote an article explaining the issues with the abuse of meta queries by many WP plugins: https://tomjn.com/2016/12/05/post-meta-abuse/ Among other things he says there: […] sites have been brought down by this, and it’s the reason a number of popular plugins don’t scale to high traffic […] … Read more

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