Questions tagged [javascript]

A client side scripting language useful for making interactive web sites. Questions about using JavaScript outside a WordPress context are off-topic but might be asked on Stack Overflow.

Filter by
Sorted by
Tagged with
0 votes
0 answers
7 views

Show a popup message when file is uploaded

I have to check if a file is already uploaded to the site when I upload a new file (it checks the md5 hash of the new file and compare it to all the other files' hashes stored into the database). For ...
user avatar
0 votes
0 answers
8 views

How do I run this code after page load on WordPress? [closed]

if(localStorage.getItem("ChangeLanguageFirstTime") === null) { doGTranslate('en|ar'); localStorage.setItem("ChangeLanguageFirstTime", true);} I need to add this script after page ...
user avatar
-1 votes
0 answers
21 views

Capture the ip with a click inside the `<div id='click'>Click here</div>`? [closed]

Capture the ip with a click inside the <div id='click'>Click here</div> ? And capture the ip putting it in here $ip_array = array("xxx.xxx.xxx.xx");? <?php $ip = $_SERVER[&...
user avatar
0 votes
0 answers
16 views

Combine CSS Files without plugin

I want to combine CSS Files and JS files without plugins ; I am procedding with searching to dequeue scripts not to be in used and after that making them in one file Do anyone has an idea? Without ...
user avatar
0 votes
0 answers
21 views

Some problems in custom widget

I made a custom widget for my template, which has an image upload section For the first time, I upload an image, it displays correctly, without any problem, but when I want to change the image, it ...
user avatar
  • 1
0 votes
0 answers
9 views

How to display contact form 7 form in vanilla js without jquery in frontend

Backend jquery Frontend Vanilla JS Contact form 7 Wordpress I have a task to display a cf7 form on the frontend using vanilla javascript . From what I've read, this can be done using admin_ajax.php. ...
user avatar
0 votes
0 answers
25 views

Append html to div

I want to add custom html to a div using this function in the functions.php file. I'm not sure why this isn't working. function add_html_under_div() { ?> <script type="text/...
user avatar
0 votes
0 answers
19 views

Call a function in functions.php from within <script> tags (JS)

I have a pretty simple problem (I think) which I can't find an answer to. The setup is pretty basic. I have a function which is in functions.php: function function_A($variable) { return $variable +...
user avatar
  • 111
0 votes
0 answers
11 views

Change each text after 4 second and each image after 2 second

Basically first two images(image1, image2) from array depend on first string(String1) from array. and other two images on String2, so i want string1 change after 4 second but in this time two images ...
user avatar
0 votes
0 answers
18 views

How to write a shopping queue line plugin with a queue button?

I am familiar a little with HTML and Css and an epsilon with PhP, Js, SQL and JavaScript. I want to write a shopping queue line plugin with a queue button (If there is no similar free WP plugin) such ...
user avatar
  • 101
0 votes
0 answers
16 views

wp_enqueue_script JS code runs too late (after user begins interacting)

The issue is that we need to replace some HTML based on the user's user agent string but by the time the JS code is loaded and runs, the user is already interacting with the page. Is there some way to ...
user avatar
  • 111
0 votes
0 answers
21 views

How to sort posts by active category in Wordpress?

I want to sort posts by active category, can you tell me how it can be done?
user avatar
  • 1
0 votes
1 answer
54 views

wp_handle_upload returns a critical error response or invalid form submission

Trying to make a plugin that can upload files directly to WP. Despite copying different blocks of code online, it seems determined to not let me upload it. The way I'm attempting is through a ...
user avatar
2 votes
0 answers
41 views

Developing the save function in Gutenberg blocks

I am editing the save function on my local wordpress instance. Every time I make a change, I need to manually click the "Attempt Block Recovery" button to see the updated change when I go to ...
user avatar
  • 133
1 vote
2 answers
58 views

Custom Gutenberg block: access dom element via JavaScript

I'm developing a custom Gutenberg block and would like to use the same JavaScript code on frontend and backend. In the save function of the block I generate the following html code (abridged): return (...
user avatar
0 votes
1 answer
23 views

Hook a script as the very last one before the closing body tag

I'm trying to add a script in the very last position before the closing via function.php Other scripts are hooked by other plugins, so WP is placing my script as the firts one of the list. Like: [my ...
user avatar
0 votes
1 answer
13 views

Block pattern conflict with custom block

I have created a custom block named testimonials and saved it as a pattern. The problem is when I make some modifications to the block save function it doesn't match with the pattern anymore and I get ...
user avatar
  • 113
0 votes
1 answer
30 views

Problem extending a core block

I need to make a search block by creating a new instance of the core / search block (a basic wordpress block). I tried with the registerBlockType function with which I get this error message: ...
user avatar
0 votes
0 answers
9 views

Directorist - Dropdown doesn't open

I am using the Directorist plugin, and in the Filters, the select dropdown has a bug in it. What I found out is that it is a SPAN with a SELECT inside. This is the page with the filter on the end of ...
user avatar
  • 1
0 votes
0 answers
44 views

How to import a JavaScript Library into WordPress

I'm trying to integrate the 'Rough Notation' JS Library into my WordPress website. See: https://roughnotation.com/ https://github.com/rough-stuff/rough-notation I'm just using their basic demo code (...
user avatar
  • 103
0 votes
2 answers
40 views

Wordpress - Get Posts with Category data

i have a question about improving my solution. For my task i build a Gutenberg block which shows the latest 5 Posts. This Posts show also the Category Name in the Frontend part which have different ...
user avatar
  • 3
0 votes
1 answer
40 views

How to change ```<h2>``` to ```<h2 data-splitting>```?

How to change the heading tags <h1> to <h1 data-splitting> and <h2> to <h2 data-splitting> and <h3> to <h3 data-splitting> and <h4> to <h4 data-splitting&...
user avatar
1 vote
0 answers
28 views

Custom Block - save.js function not saving attributes

I'm trying to get just a basic custom block displaying in the editor and saving. I've followed multiple tutorials and I keep getting the same result. No matter how simple my block is, whenever I add a ...
user avatar
  • 11
0 votes
0 answers
22 views

Trigger a JavaScript function based on the data fetched from Woo commerce hook

I have read quite a lot of possible ways to do it but after going through each of them I'm still not able to understand what should be the correct way of doing it and how the correct way works. ...
user avatar
0 votes
1 answer
62 views

Meta field bulk editing no longer working in WP 6.0 [closed]

Until recently, I was using the following PHP and jQuery code for adding bulk editing support for a meta field (price) in a custom post type (Book): PHP: function show_bulk_edit_book_metabox( $...
user avatar
  • 1,637
0 votes
0 answers
27 views

Ajax call not working in wordpress through a plugin

I have 2 Ajax call the first is working but when it send the data to other the file send_data.php and when I try to run any wordpress function which is add_post_meta it doesn't work! This's the first ...
user avatar
  • 5
0 votes
1 answer
20 views

Send Array from JS to php file then insert it in wp database through a plugin

This's my code it's success but when but I can't the return data from ajax in the same page. the mechanism is the user click the dropbox button and when he selects it returns dropbox_links and then ...
user avatar
  • 5
0 votes
0 answers
18 views

how to let users upload their custom cover image

I have a dashboard for users (one page using elementor and buddyboss to change stuff like name profile pic etc). I want users to be able to upload a custom cover image. I found some code that almost ...
user avatar
0 votes
0 answers
15 views

Get uploaded attachment width & height and attachment ID after upload them

I will explain my requirement here. Im trying to redirect window to wordpress image editor once image is uploaded via wordpress image upload window. also this redirection should only happen if image ...
user avatar
0 votes
0 answers
11 views

imporing HTML+javascript from REST API

i got a new task - move my front to VueJs, so now i have to return forms through API's here is an example of my Endpoint: return do_shortcode(get_field('ninja_form_shortcode', $document->ID)); The ...
user avatar
2 votes
1 answer
40 views

How to add Internationalization in WordPress using Javascript/React?

I am trying to follow this article https://developer.wordpress.org/block-editor/how-to-guides/internationalization/ in order to translate my block. I created my block using https://developer.wordpress....
user avatar
0 votes
0 answers
12 views

how to use nimble-API and Display data?

I want to get the contact resources displayed by doing Nimble API, but I do not know how these resources are displayed. How can I change the JSON code in PHP? [this is the link I check but can not ...
user avatar
  • 1
0 votes
1 answer
16 views

How to redirect non logged in mobile users to page on same site?

I have seen many like this question (like How to redirect non-logged in users to a specific page?) but none have worked. this is basically what I've come up with but it doesn't work all the time and ...
user avatar
0 votes
0 answers
17 views

Plugin URL in JS [duplicate]

In my plugin I need to include a localization JSON resource for an external library I'll be using. The localization for the particular library gets invoked like this: $('#table-id').DataTable( { ...
user avatar
  • 121
0 votes
0 answers
18 views

Get localize of a loaded javascript

I am writing a cache code to combine JS files I add JS files in a single file and then dequeue the script using wp_dequeue_script But the problem is wp_dequeue_script will dequeue extra inline data (...
user avatar
0 votes
1 answer
25 views

How do I add <div> tags to entire comments, not just their text

Thanks to some wonderful help here at stack exchange, I have built a comment section with a dropdown menu that adds comment_meta to the comments. I currently have a working filter that uses GET to ...
user avatar
0 votes
1 answer
27 views

Trigger wp-embed via JavaScript to refresh iframe preview?

I'm running WordPress 6.0 and using the Block Editor to enable content editors to paste links that generate the embed/iframe preview, as described here. I've noticed from time to time (i.e. ...
user avatar
  • 217
0 votes
1 answer
14 views

Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?

I'm trying to create a dropdown selector on my CPT and CT archive page for a custom taxonomy called "location". I've managed to get the form to submit, however, it does not direct me to the ...
user avatar
0 votes
1 answer
52 views

How to use wp_send_json() and output the value with ajax?

Hello Wordpress Developers. I create my own plugins, and I'm stuck about how to call php functions inside class, into javascript ajax functions. For example we have button with ID name clickme: <...
user avatar
  • 5
0 votes
1 answer
61 views

Translate javascript with WordPress built-in localization API for static strings

I have been trying to implement the translation to a couple of strings in a .js file but nothing has worked. First try to do it like I do in php, in the .js file add this variable var __ = wp.i18n.__; ...
user avatar
  • 17
0 votes
1 answer
31 views

Set Button in PluginDocumentSettingPanel Content (Wordpress Gutenberg)

I'm trying to create a new panel in the edit-post sidebar (Wordpress Gutenberg), I already managed to set the panel with the title and the text in the content part but I need to add a button there and ...
user avatar
  • 17
0 votes
0 answers
27 views

enqueuing external and internal js and css in wordpress did not work with owl.js animate.css

<?php function cadentic_files () { wp_enqueue_script('cadentic_owl_carousel',get_theme_file_uri('js/owl.carousel.min.js'), array('jquery'), time(), true ); wp_enqueue_script('...
user avatar
0 votes
0 answers
27 views

Hook on file upload

I need a hook or some way to detect when the window to select the file to upload is opened. I'm talking about the window that opens the browser to select the local files to upload. Context: On ...
user avatar
  • 17
1 vote
1 answer
116 views

Gutenberg add extra attributes to custom format

I'm creating a custom format (adding a custom option to the format toolbar) using the following guide: https://developer.wordpress.org/block-editor/how-to-guides/format-api/ import { ...
user avatar
  • 357
0 votes
0 answers
32 views

Using Ajax to submit a form, and run a SQL Select query based on user input from the form

I'm creating a web form on my WordPress powered website. The form is intended to allow the user to enter a ZIP Code (aka postal code). When the user submits the form, the page should query a MySQL ...
user avatar
  • 1
1 vote
1 answer
37 views

Very simple wordpress block to display posts from an api call

I've been banging my head on this for a bit now. I'm trying to create a simple wordpress block that fetches custom post types from the rest api, then displays the fetched posts via react. It only ...
user avatar
0 votes
0 answers
27 views

Hot to check if new posts have been published since page load and notify online users?

I want to show a div notifying online users that there are new posts since they have accessed the page, in the index and also if new posts have been added in the category or tag they are browsing. I ...
user avatar
0 votes
0 answers
25 views

Dynamically add Js

I have a basic bunch of CSS/Js files defined in my functions.php file. There I register and enqueue those scripts and stylesheets. But in specific situations I want to load additional scripts based on ...
user avatar
2 votes
1 answer
36 views

Javascript code inside "<# #>" in core WordPress files .php

I found some interesting embeding JavaScript mix with HTML in WordPress php files, for instance: <?php // Template for the Attachment Details two columns layout. ?> <script type="text/...
user avatar
0 votes
0 answers
38 views

JS / jQuery in Elementor pages vs JS file

I have a lot of JavaScript and jQuery functions that are all working fine, but it's quite fragmented and hard to maintain as some are in Elementor HTML widgets, others in specific Pho functions annd ...
user avatar

1
2 3 4 5
52