Javascript localization doesn’t load. How to Internationalize javascript without plugin?

Good News after 2 days! I resolved my issue, but I believe that wp i18n make-json does not generate the json file correctly. Why? Because it uses the ISO codes and not the locale (get_locale()) from the browser/user. So it isn’t “en_GB” that should be used but “en” in the .json file. This : “locale_data”: … Read more

Help with adding fullcalendar.io to a WordPress page

Figured it out! First I passed what Iceable suggested and also added moment script above, like so wp_register_script(‘moment’, “https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js”); wp_register_script( ‘fullcalendar’, “https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.js”, array( ‘jquery’ ), null, true); and then I edited JS like so jQuery(function ($) { $(‘#calendar’).fullCalendar({ }) }); And it showed up!

Registered a REST Route but I’m Getting a 400 Bad Request

Make sure you’re reaching the correct endpoint by using rest_url(). When using the REST API and nonces, make sure that the nonce action is set to ‘wp_rest’. add_action(‘enqueue_block_editor_assets’, function () { $data = wp_json_encode(array( ‘restUrl’ => esc_js(rest_url(‘guide-posts/v1’)), ‘nonce’ => esc_js(wp_create_nonce(‘wp_rest’)) )); wp_add_inline_script(‘guide-posts’, “var guidePostsAjax = $data”); }); The permission_callback property is mandatory when registering a … Read more

WordPress send Ajax where click button

@sergio Here is the working answer you can check if there is still any issue paste it here and it if it works well you can upvote the answer to help others. The issue it when you click button your $(this).prop(‘files’)[0] is not working because not this scope to the button element. $(‘body’).on(‘click’, ‘#enviar_fichero’, function() … Read more

How can i add a script with parameters?

Use wp_enqueue_script from your PHP code to register and enqueue a script. WordPress will then handle automatically adding the required script tags at the right place and you’ll be able to instantiate and use the API from your javascript. E.g. (untested, check the docs for your use case) wp_enqueue_script(‘googlemaps’, ‘https://maps.googleapis.com/maps/api/js?&key=KEY’);

How do I remove/hide embed excerpts from posts

I was able to remove those excerpts with the following code in functions.php remove_filter(‘get_the_excerpt’, ‘wp_trim_excerpt’); Keep in mind that I’m using a theme “Newspaper” for other excerpt settings, which are not affected by the above code

Giving each loop post unique numbers so that WordPress would treat separately

Change your <video> id to be a class, so that there can be multiple of them on a page. Use .querySelectorAll(‘video.local-video’) to get all video elements with the class name of .local-video. Loop through all of those elements, and play them accordingly. Code: <!– Autoplay, on view video START–> <script> const localVideos = document.querySelectorAll(‘video.local-video’); // … Read more