Hot answers tagged

3

To extend on @gmazzap suggestion on not using globals when you can use wp_scripts(), there is a shortcut for wp_scripts() for adding conditional comments called wp_script_add_data and likewise wp_style_add_data for conditional styles. So the correct way to use conditionals as of Wordpress 4.2 is like this: /** * IE enqueue HTML5shiv with conditionals * ...


3

PHP wp_enqueue_scripts is a good time to localize the data. Make sure you target your script and create a name for the object as well as passing an array of data. In this case twitter_settings is the object that will be created and will hold all the data. twitter_settings.tweets_widget_id will ultimately hold your $tweet. add_action( 'wp_enqueue_scripts', ...


1

You need to loop through your posts, and retrieve the metadata for each post. Add them to your array, and encode them to JSON. $posts = $query->get_posts(); foreach( $posts as &$thispost ) { // reference the current item $thispost->meta = get_post_meta( $thispost->ID ); } Now you got a WP_Post-Object, with all the post meta available at ...


1

This line in functions.php is your problem: $cat_id = get_post_meta($_REQUEST['cat']); I think you are misunderstanding the purpose of the get_post_meta() function. It is designed to get metadata for a WordPress Post, not data from a POST request to the site. The first parameter of the get_post_meta() function is the $post_id, but since you are passing ...


1

wp_logout is being triggered server side when the user is logging out, but the fact that it is being triggered do not indicate that there is a browser on the other side that actually triggered it. For example a user might log out via Ajax and then the JS code will not be evaluated. In any case, it is much better to define a logged out user as one that do ...


1

Add a autocomplete 'select' catch to your first autocomplete field. Use this to get the chosen value from the autocomplete. Use an Ajax call to obtain your next autocomplete source based on the selected value and apply the new source to the next autocomplete field. jQuery( "#cns-make" ).autocomplete({ source: availableTags, select: function (event, ...


1

It looks like your javascript (which is formatting your menu) is only running after page load. You have quite a few includes so I didn't check them all, but make sure your theme is running its setup script on document ready. Like this (for jQuery). $( document ).ready(function() { //run script here }); Also, you could try manipulating the menu CSS. ...



Only top voted, non community-wiki answers of a minimum length are eligible