Slow wp_enqueue_media()

To load admin scripts only on your pages, you should use the $hook-parameter: function enqueue_scripts( $hook ) { if( ‘my-page’ != $hook ) return; wp_enqueue_script(‘jquery’); wp_enqueue_media(); // etc… } add_action(‘admin_enqueue_scripts’, ‘enqueue_scripts’); Concerning the loading problem. This seems to be still an open problem. The ticket 27985 was followed up by #32264, which is not closed … Read more

author.php with ACF and CPTs

REWORKED APPROACH The issue with the original answer is that although we pass post ID’s to post__in parameter, being on the author page, the main query removes all posts that does not belong to the author. We can pass an empty string to author_name via the pre_get_posts filter, but that inherintly breaks the query object, … Read more

Custom query_var causes displaying posts archive on front page

After detailed debugging of WP::parse_request() and WP_Query::parse_query() I found out that unset( $query_vars[‘date’] ); in ‘request’ filter helps. It basically unsets date query var before WP_Query::parse_query() is invoked so is_home() returns false. add_filter( ‘request’, function( $query_vars ) { global $wp_query, $wp; if ( ! $wp_query->is_main_query() ) { return $query_vars; } $qv_keys = array_keys( $wp->query_vars ); … Read more

Add multiple value to a query variable in WordPress

I am giving you some solutions whatever you want to use. Using plus http://myexamplesite.com/store/?brand=nike+adidas+woodland //Don’t decode URL <?php $brand = get_query_var(‘brand’); $brand = explode(‘+’,$brand); print_r($brand); ?> using ,separator http://myexamplesite.com/store/?brand=nike,adidas,woodland $brand = get_query_var(‘brand’); $brand = explode(‘,’,$brand); print_r($brand); Serialize way <?php $array = array(‘nike’,’adidas’,’woodland’);?> http://myexamplesite.com/store/?brand=<?php echo serialize($array)?> to get url data $array= unserialize($_GET[‘var’]); or $array= unserialize(get_query_var(‘brand’)); print_r($array); … Read more

How to display Section for certain time

Check the time parameter on WP_Query Class. There is a example on how to show posts form last 30 days. You can do it for last couple of hours, minutes or even seconds! Code is tested and working. $args = array( ‘posts_per_page’ => 1, // We are showing only one post ‘category_name’ => ‘prime’ // … Read more

How to order WP_User_Query results to match the order of an array of user IDs?

Updated: The WP_User_Query class, in WordPress 4.1+, supports it with : ‘orderby’ => ‘include’ Since WordPress 4.7 there’s also support for: ‘orderby’ => ‘login__in’ and ‘orderby’ => ‘nicename__in’ So we no longer need to implement it through a filter, like we did here below. Previous Answer: I wonder if this works for you: add_action( ‘pre_user_query’, … Read more

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