js file in root loading without

WordPress has no mechanism to load custom js files automatically. If your theme need that js file, then place it inside your theme folder. and link it in your template file. for example, <script src=”https://wordpress.stackexchange.com/questions/353972/<?php echo get_template_directory_uri(); ?>/assets/bootstrap.min.js”></script> In the above example, “bootstrap.min.js” file is located in my theme’s “assets” folder. the function get_template_directory_uri() return … Read more

WordPress on localhost working, when sharing IP to connect receive err_connection_refused on .js and .css files

As discussed in comments, the problem was that the site address was set to localhost:8888/myBlog. This is the URL WordPress is expecting your clients to be using, and uses this to generate fully-qualified URLs for scripts and CSS etc. Hence your other clients were trying to load scripts and CSS from their own localhost. The … Read more

can a buttongroup have a label?

I have discovered a way of creating a label and a help property for a component that doesn’t have it’s own label or help properties, by wrapping that component in a BaseControl component. Here is my working solution: createElement(PanelRow, {}, createElement(BaseControl, { label: __(‘N element alignment’, ‘my-textdomain’), help: __(‘Set the alignment for n element in … Read more

event/callback on block update?

You might try a useEffect hook subscribed to the attributes.identifier to call the script. something like: function Edit( { attributes, setAttributes } ) { useEffect( () => { // this will fire whenever the attribute changes. thirdPartyScriptFunctionName(); },[attributes.identifier]) const onChangeIdentifier = (value) => { setAttributes({ identifier: value }); }; return ( <div id = {`embed-${ … Read more

How to get the parent of a non-hierarchical custom post type being edited in Gutenberg

You are already using the correct Gutenberg/JS code, but it’s a limitation in the REST API which exposes the parent field only for hierarchical post types like page. But you can force the field to appear in the REST API responses via register_rest_field() — example for a my_cpt post type: register_rest_field( ‘my_cpt’, ‘parent’, array( ‘schema’ … Read more