How do I enqueue(or delay loading of) tags in individual page posts?

General answer: you can call wp_enqueue_script() directly inline in the template, as of WordPress 3.4 (IIRC). So, if you have: <script src=”https://wordpress.stackexchange.com/questions/82668/myscriptforthispageonly.js”></script> You could replace it with: <?php wp_enqueue_script( ‘this-page-script’, get_template_directory_uri() . ‘/myscriptforthispageonly.js’, array( ‘jquery’ ), null, true ); ?> Edit From this comment: This is from within a page. As in a WordPress page. … Read more

Run shortcode at certain resolution

Ok, let’s clarify the concept. You don’t want download the content for mobile device, and you want to rely on screen resolution. You know that php (wordpress) run on server, screen resolution is a completely client-side matter. So the flow will be: user send a request to your site your site page load on client … Read more

Filter medias from the Media Uploader (wp.media) modal with a post meta

Simplest part is to filter attachment list. Use this code add_filter(‘ajax_query_attachments_args’, function($args) { $args[‘meta_query’] = array( array( ‘key’ => ‘my_image_meta’, ‘value’ => $some_value, ‘compare’ => ‘=’ ) ); return $args; }); However this code will filter all media library queries. You may want to pass some additional parameter from wp.media. This answer may be helpful.

How to control contextual help section by code?

You could also trigger/simulate the help button being clicked by binding to the ready event. Pre jQuery 1.7 <script type=”text/javascript”> jQuery(document).bind( ‘ready’, function() { jQuery(‘a#contextual-help-link’).trigger(‘click’); }); </script> jQuery 1.7+ (bind deprecated as of 1.7) <script type=”text/javascript”> jQuery(document).on( ‘ready’, function() { jQuery(‘a#contextual-help-link’).trigger(‘click’); }); </script> The difference here is that you’ll see the help section slide down … Read more

Linking to Files in Root Directory Outside of WP Installation

Your first attempt does not work because get_template_directory_uri returns the URL to your theme directory. Your second attempt will work, but if you don’t want to hard code the domain you could either try using a root relative path or fetching the domain portion of your site url. Relative path: wp_register_script(‘circle-bounce’, ‘/js/general.js’, array( ‘jquery’, ‘jquery-effects-core’, … Read more

Dynamic data in `wp_register_script` needed

You are looking for the wp_localize_script() function. This function allows you to add data from server to your javascript. However, this will not change the content of jsfile.js. Instead, it will add some global variable in your theme’s footer.Changing the content of a JS file before outputting it to the browser is an advanced technique, … Read more

Shortcode to Gutenberg-block: additional text on front-end and conditional display

Although a little different than I had initially anticipated, I have found/created a solution to my two problems. Conditionals I have opted to move non-required input to the sidebar, using the InspectorControls-element. Reason for this is that I realised that it would be impossible to hide a field (in the editor-part of the screen) that … Read more