Using WP_Query to grab custom meta values, foreach to json object

The best way to go about this is with $wpdb. The query to draw out meta_value by category is: $query = $wpdb->get_results( “SELECT p.`ID`, pm.`meta_value` FROM {$wpdb->postmeta} pm LEFT JOIN {$wpdb->posts} `p` ON `p`.`ID` = pm.`post_id` LEFT JOIN {$wpdb->term_relationships} `tr` ON `p`.`ID` = `tr`.`object_id` LEFT JOIN {$wpdb->term_taxonomy} `tt` ON `tr`.`term_taxonomy_id` = `tt`.`term_taxonomy_id` WHERE `pm`.`meta_key` = … Read more

WP http XML response HTML encoding and image display problems

Registering dependencies WordPress uses the Dependency API for that. It’s fairly simple: Register & enqueue a script, then pass data that you want to pass from WP/PHP to JS using wp_localize_script(), which adds a <script> tag containing an Array to your DOM (exactly before your script gets added to it): add_action( ‘wp_enqueue_scripts’, function() { $name=”handle”; … Read more

Passing jQuery into the WordPress media uploader

As you mention the media uploader dynamically renders the images “on demand” and there doesn’t seem to be an event one can target to add the class. A gross way to do it is to override the wp.media.view.Attachment.Library.className attribute (before the frame is created) to return the extra class if the model id is in … Read more

Limit filetype and wp media

I have shown your questions and i have found correction in it. You need to update your code as below. .on( ‘select’, function() { var attachment = custom_uploader.state().get( ‘selection’ ).first().toJSON(); if(attachment.mime == “image/jpg” || attachment.mime == “image/jpge” || attachment.mime == “image/png”) { jQuery( ‘#previewImage’ ).attr( ‘src’, attachment.url ); jQuery( ‘.custom_media_url’ ).val( attachment.url ); jQuery( ‘.custom_media_id’ … Read more

Why does javascript works only if logged in?

Try: wp_enqueue_script( ‘nevermind-navigation’, get_template_directory_uri() . ‘/js/navigation.js’, array(‘jquery’) ); It is possible that jQuery is not enqueued, and you are not declaring it as a dependency for your script. Being logged in, automatically enqueues jQuery. EDIT: Console log says jQuery is not defined. Did you add a jQuery(document).ready($) function for the fixed-menu.js functions?