Changes to JS not reflected on site

You have to look through your theme to see where the js file is enqueued. Usually there is a functions.php file in the theme which will have all the special functions and actions. Sometimes the developer will put all the enqueued scripts into the theme template (i.e. single.php) before get_header() is called. In any event, … Read more

Modals using loops and ACF [closed]

You’re right you should be using an id. I would use a counter in conjunction with get_the_ID(); $arr_posts = new WP_Query( $args ); if ( $arr_posts->have_posts() ) : $index = 0; while ( $arr_posts->have_posts() ) : $arr_posts->the_post(); echo $index . ‘_’ . get_the_ID(); endwhile; endif; This will give you a unique id which you can … Read more

How can I get the standard WP-Editor through Javascript?

Ok I found the solution here Just do wp.editor.initialize(‘editor_id’, { tinymce: true, quicktags: true }); And then add buttons to the toolbar like so: jQuery( document ).on( ‘tinymce-editor-setup’, function( event, editor ) { if(editor.id !== ‘editor_id’) return; editor.settings.toolbar1 += ‘,mybutton,alignleft,aligncenter,alignright,fontselect,hr’; editor.addButton( ‘mybutton’, { text: ‘My button’, icon: false, onclick: function () { editor.insertContent(“It’s my button!”); … Read more

How can I add Block Style support to the core HTML block in Gutenberg?

Block Style Variations allow providing alternative styles to existing blocks using filters, as explained here. Here are some examples for your case using the server-side functions (php). You can either add the css style inline: register_block_style( ‘core/html’, array( ‘name’ => ‘full-width-video’, ‘label’ => __( ‘Full Width Video’ ), ‘inline_style’ => ‘.wp-block-html.is-style-full-width-video { width:100%; }’, ) … Read more

Vimeo froogaloop

so I’m not sure the enqueuing is even happening No, it’s not, because you only registered the scripts, but never enqueued them — which should be done using wp_enqueue_script(). Also, you should make frogaloop as a dependency for your snippet.js script. Hence, register the frogaloop script before your snippet.js script. // Register the scripts. wp_register_script( … Read more

Can the index.asset.php file be used with the enqueue_block_editor_assets action?

Yes you can use the index.asset.php file in the ‘enqueue_block_editor_assets’ action. I guess you missed to npm install the dependencies you want to use and import them in your script. That’s how @wordpress/scripts generates your asset.php file. If you do not import the dependencies in your JavaScript files the dependency management of asset.php wont work. … Read more

How to Add Javascript Only When a Function Exists?

Hi @Denis Belousov: Okay, based on your responses I’m going to ask why tie it to the function existing, why not just test the return value of get_option(‘src_switcher’) like this? function my_scripts() { if (!is_admin()) { wp_enqueue_script(‘jquery’); wp_enqueue_script( ‘custom’, get_bloginfo(‘template_directory’).’/js/custom.js’, array( ‘jquery’ ), ”, true ); if (is_front_page()) { $sliders = get_option(‘src_switcher’); if ($sliders == … Read more

Script will not print in head if path to file is correct

How about using locate_template() for the inclusion and wp_enqueue_script() for the scripts? There’s also content_url() to target /wp-content/. Also: How did you inspect it? Sourcecode? FireBug? Try to open source in FF and then click the link. If you get a “file not found”, you know what it’s about, else it should be loaded. The … Read more