How to get the post_name when in preview?
is_preview() is supported. You may also want to look into is_singular() which covers posts, pages, and attachments.
is_preview() is supported. You may also want to look into is_singular() which covers posts, pages, and attachments.
There is a generic way to use conditional comments – for styles. But unfortunately not for scripts until #16024 will be fixed. The details are described in this answer. To make your themes scripts filterable you could use a callback on wp_print_scripts and apply a custom filter in there. /** * prints a conditional comments … Read more
https://stackoverflow.com/questions/22813970/typeerror-window-tinymce-execinstancecommand-is-not-a-function Thanks to Scott B In WordPress 3.9, the TinyMCE is updated to version 4, and in TinyMCE 4, the method “execInstanceCommand” has been replaced by the method “execCommand”. For compatibility issue (with old versions of WP), you must be check the TinyMCE version and used the suitable method. In below, i changed your code. … Read more
I was able to solve this by looking into the inner .iris() and check that it has a .(‘color’) method that allows to set a color at runtime. Thankfully, this .(‘color’) method is supported too by .wpColorPicker(), so one can do: var new_color = $the_related_field.val(); $the_colorpicker.wpColorpicker(‘color’, new_color); to overcome the annoyance of not having an … Read more
I found the solution to my problem was to change my_data.data.my_key to my_data.my_key. For example: $( document ).on( ‘click’, ‘#button’, function() { var my_data = wp.heartbeat.getQueuedItem( ‘my_handle’ ); alert( my_data.my_key ); }); The queued data can be easily accessed now.
The jQuery library packed with WordPress, operates under noConflict mode. Means you can not use $ in your jQuery snippet/code. Either use jQuery instead of $. or use noConflict wrapper like this. <script type=”text/javascript”> <!– jQuery(document).ready(function($) { // your jquery function, you can use $ here. }); // –> </script>
To print JavaScript code to your page, you have several paths to choose from. The most obvious would be the wp_footer action. Just hook a function to it and make it print your JavaScript/jQuery code, wrapped in <script /> tags. // EDIT As an addition, if your custom JavaScript/jquery code is static (i.e., there are … Read more
Your code should look like this function my_scripts_styles() { wp_register_script(‘easing’, get_template_directory_uri() . ‘/js/easing.js’, ‘2014-12-030’, true ); wp_enqueue_script(‘easing’); } add_action( ‘wp_enqueue_scripts’, ‘my_scripts_styles’ ); The above code should work fine. Also don’t forget to check if you have properly specified the path to your js file. Check well that you have a functions.php and not function.php file. … Read more
Updating the url via javascript, is not related to WordPress, however you just need to modify window.location.hash in your jQuery code. Regarding the usage of admin-ajax.php it is recommended way to do tasks via AJAX that need to load WordPress environment, instead of manually requiring wp-load.php. In your case you are sending a request to … Read more
Proper object names First, make sure you are using the proper object names. Instead of using label for checkboxes; use text instead. (TinyMCE Checkbox Syntax) onsubmit: When using the onsubmit() function; the information from the form is passed into the function. So, we can use the first argument of the function to check for form … Read more