Accessing javascript in multiple files [closed]

You have to create a dependency with wp_register_script($handle, $src, $dependency, $version, true/false); See WP codex: wp_register_script and then make sure that the second file is loaded correctly and right after the initial script. The third parameter is an array for dependencies/other “handles”. So..in your case: <?php // Functions.php or somewhere else wp_register_script(‘my_first_script’,get_template_directory_uri().’/js/my-first-script.js’, array(‘jQuery’), ‘1.0’, true); … Read more

Access post title from custom meta box on title change

The event listener you have added will only attach to the available .editor-post-title__input elements, and won’t attach to any dynamically added elements. You are better to move the listener to the body as follows: jQuery(‘body’).on(‘keyup’, ‘.editor-post-title__input’, function(event){ console.log(jQuery(this).val()); }); Given the admin area is moving to use more React components, it’s a good habit to … Read more

wp_nav_menu not working correctly in my underscores theme

If found out that this is removing my menu: function add_menu_icon ( $items, $args ) { if ( $args->theme_location == ‘primary’ ) { $elements=”<li class=”custom-logo”>” . get_custom_logo() . ‘</li>’; $elements .= $items; $items = $elements; return $items; } } add_filter( ‘wp_nav_menu_items’, ‘add_menu_icon’, 10, 2 ); I still haven’t figured out why.

Insert Into Post Not Working For Audio File Using jQuery

I have come up with better and new working version that supports all file types which I am going to share here in case anyone else is looking for this answer. Input field added to metabox <input type=”text” name=”sermon_mp4″ id=”sermon_mp4″ value=”<?php echo $sermonmp4; ?>”/> <input type=”button” id=”sermon_mp4_button” value=”Add Sermon Audio” /> jQuery <script type = … Read more

How to keep HTML form field that is conditional hidden with javasript hidden after page reload?

Try this code: // Conditionally show price (function ($) { window.onload = function() { if ($(“#select_price_option”).val() == “I need more information”) { $(‘#price_input_div’).hide(); } $(“#select_price_option”).change(function() { if ($(this).val() == “I need more information”) { $(‘#price_input_div’).hide(); } else { $(‘#price_input_div’).show(); } }); }})(jQuery);

Return ‘X-WP-Total’ from headers in response

Ideally, you can access those headers with response.header, but not all headers are available publicly unless exposed manually. In your case, to access X-WP-Total by the client, you need to set the Access-Control-Expose-Headers header on your server: Access-Control-Expose-Headers: X-WP-Total