How to pass jquery as dependency to a script that has the module type added to the tag programmatically?
How to pass jquery as dependency to a script that has the module type added to the tag programmatically?
How to pass jquery as dependency to a script that has the module type added to the tag programmatically?
If you plan to do a lot of WP development you should bookmark this page: http://codex.wordpress.org/Conditional_Tags The other answer works but the conditional relies upon your page slug (myurl.com/this-is-the-slug) never changing. A more reliable method (IMO), and one that fits this case, would be to use the is_page_template(‘example-template.php’) conditional check instead.
As the warnings say, $post is used but not defined, hence “Undefined variable $post” and then ‘Attempt to read property “ID” on null’. It seems like the global $post is in an erroneous location and should be before the if statement: global $post; if ( is_singular() && wp_attachment_is_image ( $post->ID ) ) You may also … Read more
This fixed my issue, hopefully it can help someone else. <?php add_shortcode(‘city_dropdown’, ‘city_taxonomy_dropdown’); function city_taxonomy_dropdown( $atts ) { // Attributes $atts = shortcode_atts(array( ‘hide_empty’ => ‘1’, // or ‘0’ ‘show_count’ => ‘0’, // or ‘0’ ‘orderby’ => ‘name’, // or ‘order’ ‘taxonomy’ => ‘city’, ), $atts, ‘city_dropdown’); ob_start(); ?> <select class=”<?php echo esc_attr($atts[‘taxonomy’]); ?>” name=”<?php … Read more
Why can’t you check loaded scripts in source code? All the scripts will be listed there, unless you minified them.
Your code seems correct, but the problem might lie somewhere else. You need to make sure that the path to your JS file is correct and the function pdocrud_admin_enqueue_scripts() is being called correctly. Also, make sure your constructor is being called in the context of a WordPress action that happens after plugins are loaded. Here’s … Read more
Add this to your URL when calling the google API: &loading=async
Custom gutenberg block refuses to load viewScript and I don’t know why
I think it’s because you’re doing your localization in the shortcode which may be messing with the order of things. Instead do this: add_action( ‘wp_enqueue_scripts’, array( $this, ‘frontend_enqueue’ ) ); function frontend_enqueue() { wp_register_script( ‘my-handle’, plugins_url( ‘js/frontend.js’, __FILE__), array( ‘jquery’ ), ‘1.0.0’, true); wp_localize_script(‘my-handle’, ‘ajax_actions’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) )); } Then… add_shortcode( … Read more
Problem solved. If there’s anybody that has the same problem as me, go into the *.php file where you’re trying to render the block. Make sure that you’re using the_content() in order to render the page content and not get_the_content().