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
6 views

How to show custom fields in modal in category page

The code below shows the title and content in the modal popup in category.php file. The full tutorial can be seen here although not important: https://artisansweb.net/load-dynamic-content-on-bootstrap-...
user3362364's user avatar
0 votes
0 answers
29 views

config @wordpress/scripts with webpack and postCSS features

I using wordpress as CMS and I want to config @wordpress/scripts with webpack and adding PostCSS and it's plugins like: postcss-loader, postcss-import, postcss-simple-vars,postcss-nested, postcss-...
Alipvd's user avatar
  • 3
0 votes
0 answers
30 views

Jest Unit tests for High order component containing Block Editor

everyone! I created High order component HOC which adds additional panel to Advanced section at the right sidebar Something like this: import React from 'react' import {InspectorAdvancedControls} ...
oshka's user avatar
  • 1
0 votes
1 answer
22 views

Implementing onSplit/onMerge in dynamic Gutenberg Custom Blocks

I’m working on a custom dynamic Gutenberg block. I’d like it to act like a normal rich text paragraph (e.g., can be split or merged as needed), rather than have multiple “paragraphs” included in one ...
bellbird22's user avatar
0 votes
2 answers
48 views

hide specific css and js files in specific page wordpress with id or without?

Hi guys i have google and searched and tested codes i finded here but nothing works, i have wordpress site and i want to make some css and js dont load in the first page because some plugins puts the ...
Milan Andjelkovic's user avatar
1 vote
1 answer
47 views

Gutenberg DatePicker component with time set to zero

I'm using the following code to get and set a date meta value for a CPT in Gutenberg (some code omitted for brevity): const [meta, setMeta] = useEntityProp( 'postType', 'activity', 'meta' )...
leemon's user avatar
  • 1,806
0 votes
0 answers
9 views

How to pass php array to external js file in WordPress

I am trying to pass my php array to my external js file. PHP if (!function_exists('myScripts')) { function myScripts() { wp_enqueue_style('my-css', get_stylesheet_directory_uri() . '/...
DigitalDesigner's user avatar
0 votes
0 answers
19 views

How to replace Avatar link in profile page with upload profile pic. button using media library and display it in profile page and all wordpress site

I am developing a WordPress theme and using the following php code and JavaScript code, I replaced the Gravatar link with a button to upload profile image using Wordpress media library, the media ...
Hatem Frere's user avatar
1 vote
0 answers
24 views

How to build BOTH non-block components and blocks present in the /src directory using @wordpress/scripts

I regularly use @wordpress/scripts for building both blocks and non-block components. Recently, I started working in a new plugin that registers both some blocks and non-block components that add ...
leemon's user avatar
  • 1,806
0 votes
0 answers
23 views

Separate typography controls for titles and meta in a custom block?

I'm building a simple dynamic custom block that shows a list of posts of a custom post type. JS: import metadata from './block.json'; import './style.scss'; const { name } = metadata; export const ...
leemon's user avatar
  • 1,806
0 votes
0 answers
16 views

Add div on query loop page change

I have a little bit of JS that is wrapping elements of a blog module in a div in order to be able to create a flexbox layout $(document).ready(function() { $(".et_pb_post").each(...
J Glasshalfpool's user avatar
0 votes
0 answers
13 views

Utilizing Node.js for Server-Side Rendering for API Services in WordPress blogposts

I have a WP blog where each post requires a unique JS code from the server side (SSR). How can I do this? I tried creating new NodeJS on Cpanel option:- But I'm getting 404 when requesting the Server ...
M.K.Dan's user avatar
1 vote
1 answer
297 views

Why is the Gutenberg editor not recognizing my updates?

I'm currently working on a Gutenberg block that includes a toggle control to hide or show content. I'm following the WordPress developer documentation, and the block behaves correctly when I toggle ...
JayDev95's user avatar
  • 169
0 votes
0 answers
20 views

Embedded data and the _fields parameter in getEntityRecords

I'm using the following code to retrieve a list of post of a custom post type named movie: const { posts, hasPostsResolved } = useSelect(select => { const query = { order: 'desc', ...
leemon's user avatar
  • 1,806
1 vote
1 answer
23 views

Javascript functions not running

I am working on creating a plugin. The first thing I do is enqueue my css and javascript files. If I view the page source, I am seeing both files loaded. The problem I am having, is I have some ...
Darth Mikey D's user avatar
0 votes
0 answers
20 views

404 error on page reload

I have created a WordPress based web app that will rely on template pages that will host some vue.js different front-end apps. I've added this code to the theme functions file to rewrite all the ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
18 views

Implement AJAX 'load more' with offset posts

I am trying to implement 'Load More' functionality via a button in a WordPress theme. We are starting by displaying the first five posts using pre_get_posts in the standard WordPress query and, when ...
Alex Ryans's user avatar
1 vote
0 answers
17 views

Keep the expansible tree (list of posts) open in the sidebar

I have created a plugin to diplay a list of posts (cpt) in a tree on the sidebar. It adds an icon [+] when posts have children. However when I click on a post the tree colapses. How can I keep the ...
Artus's user avatar
  • 92
2 votes
0 answers
49 views

Gutenberg move post/page title to Editor sidebar document panel

I have not liked the way that the post/page title in Wordpress 6 / Gutenberg is contained directly in the block editor. I have found many ways to remove it with filters and / or restyle it but ...
Walrus's user avatar
  • 131
0 votes
0 answers
24 views

How to add new ACF repeater row after removing all rows using jQuery/Javascript

I am creating a custom ACF Field within a page edit screen which I have added a div container, outside the container is 3 buttons. Add text block, add image and save. I also have a repeater field (I ...
DigitalDesigner's user avatar
0 votes
1 answer
29 views

opening and closing elementor-widget-container

I want the following and hope you can help, I have created a container in Elementor and within this container I have added element and direction row. I want to the container to toggle with a button ...
Brango's user avatar
  • 1
0 votes
1 answer
124 views

Manipulating the allowed inner blocks of a core-gutenberg-block?

I had special requirements for a Button-Block for the Gutenberg-Editor, so I built a custom block "myproject/button". Now I try to use the core/buttons block with this new button block, but ...
FbnKlmn's user avatar
  • 13
0 votes
0 answers
18 views

Script tags stripped when using presto video player in WP Courses single lesson page

I am using presto video player for lessons of courses on my website created with the plugin WP Courses. Unfortunately in some pages WP Courses uses ajax and this is maybe causing the javascript script ...
Daniele Protti's user avatar
0 votes
1 answer
35 views

Create Youtube embed block with createBlock

I was trying to use this to create a Youtube video block using JavaScript: // Define the YouTube video URL (replace with your desired URL) const youtubeVideoURL = 'https://youtu.be/NNrj0N-yTnM'; // ...
Alvaro's user avatar
  • 121
0 votes
1 answer
41 views

How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters

I wonder how to use webpack while bulding theme for WordPress the correct way. Everything is pretty easy until I have to make some unusual things. So in the most simple scenario I just have some JS ...
Mateusz's user avatar
  • 153
0 votes
0 answers
22 views

How to make Contact Form 7 work when injected via AJAX in WordPress?

I am working on a WordPress project where I need to use Contact Form 7 as part of an AJAX response to check if certain data is available. However, I am facing an issue where the form is not working as ...
CodingWeb's user avatar
  • 101
0 votes
0 answers
22 views

How to add icon to WooCommerce add to cart button

in woocommerce, I want to add an icon from the iconify library to the add to cart button of my site I made some attempts, but I did not get the desired result. I used WooCommerce hooks, but this icon ...
MahmoodZamaniNemati's user avatar
0 votes
0 answers
28 views

Does wp i18n CLI has a prototype of "update-json" file?

I correctly internationalized a javascript file from wp theme folder. Now I would like to know if Wordpress team plans to propose a CLI to update json without losing existing translation. It seems ...
imagIne's user avatar
  • 41
2 votes
1 answer
95 views

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

The internationalisation of my theme is defined in functions.php and the javascript file to be internationalised uses the wp-i18n library. The translation function __('string',text-domain'); is ...
imagIne's user avatar
  • 41
0 votes
0 answers
15 views

TinyMCE - Unable to load the editor in vue front-end plugin page

I have this code in my plugin page that is created using vue 3. I need to use the wordpress editor and I'v used the wp_enqueue_editor() function to load all the needed assets of tinyMCE. in the vue ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
78 views

Include Block Variation Within InnerBlocks

I'm registering two block variations; one for query-loop (called carousel) and one for group (called dialog). Is it possible to include the variation for group/dialog inside the query-loop/carousel. ...
SteveT's user avatar
  • 3
0 votes
0 answers
11 views

Is It Possible to Block Redirect Checker Tools from Knowing Where URLs are Redirected?

I want to block URL Redirect Chain Checker tools such as wheregoes(.)com. Is it possible to do it? For example: wheregoes com/trace/20234194180/ this url can easily tell people where my affiliate link ...
Stephen Hawk's user avatar
0 votes
0 answers
18 views

unable to find the document body in user-edit admin using javascript or CSS

I am pretty new to using js on wp and I have this pretty tame script that is supposed to find the element and replace it using textContent. I also am using a simple CSS element that has the same ...
Jocelyn Hunter's user avatar
0 votes
0 answers
18 views

difference between code for admin, user facing (css, js)

So I have two pages, user-edit.php in the admin and a page for members to edit their own profiles. There is a group of section on both that has the same coding, the same css id's, the same classes, ...
Jocelyn Hunter's user avatar
1 vote
0 answers
29 views

How to access current discussion settings in gutenberg via JS?

We're struggling with the issue that occasionally comments are disabled for a post though the editors never manually change this option in Gutenberg (comments are enabled in global settings). As a ...
Abid's user avatar
  • 143
0 votes
0 answers
25 views

Separating HTML and PHP from the Script?

So I have this code which makes the infinite scrolling effect in WordPress. It fetches the title and read more correctly. The problem I find with this code is when I want to insert complex code that ...
RaymondM's user avatar
0 votes
0 answers
14 views

Identify and style the paragraph beginning w/o a class: based on a combination of common characters (CSS, JS)

There are html-constructions: <p>— Some random text.</p>. Without class. According to the specified attribute "dash, space, some random text.", I need to catch this condition and ...
milcheloveck's user avatar
0 votes
0 answers
20 views

Programmatic replacement of Publish date with Modified date does not work outside the_content area

I am having a problem replacing the Publish date with the Modified date when the theme is created using Avada Theme Builder. The following code works fine on a theme created with Elementor: add_filter(...
bee's user avatar
  • 1
0 votes
1 answer
29 views

How to add a css class to postTitleWrapper in Gutenberg?

while working with react/JS is slowly getting easier, at times I'm still surprised why things don't work as I expect them to. Here, I'm trying to add a class to the '.edit-post-visual-editor__post-...
yms's user avatar
  • 35
0 votes
0 answers
31 views

I need to optimize a website and I want it to import the js libraries only when I need themL

My problem is that I need to optimize a website, one of the ways is by removing that JS that is not used in the page, the website is quite large, I have managed to remove that JS that is not used but ...
Miguel Angel Salas8's user avatar
0 votes
1 answer
34 views

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

So I got this code right now. The problem I get is that it executes only for the first video. I know I need to give each loop post a unique number in order for WordPress to treat them separately. Same ...
RaymondM's user avatar
0 votes
1 answer
153 views

Masonry gallery block is working in the block editor but not the template editor

I'm building a custom Masonry (non-jQuery version) gallery block and I managed to make it work in the block editor. I'm using WP 6.3. This is roughly the code: JS: const containerRef = useRef(null); ...
leemon's user avatar
  • 1,806
0 votes
1 answer
42 views

How do I remove/hide embed excerpts from posts

How can I remove post excerpt from internal links that are embed as posts to custom WordPress page. https://prnt.sc/6e07tjSht5i7 I cant do it with classic CSS styling , I guess due to the iframe/embed ...
Acidburns's user avatar
0 votes
0 answers
270 views

Gutenberg block: add a multi-select for posts

I created a custom Gutenberg block with @wordpress/create-block. I now have a dropdown where you can select a post, but I would like this to be a multi-select where you can select multiple posts. How ...
azrac's user avatar
  • 1
0 votes
0 answers
47 views

REST API not returning all tags - is there a way to return all tags even ones that are not part of published posts?

I am using the REST API to upload posts and I include tags with them. I get existing tags and check them to ensure I am not trying to upload a duplicate tag. However, the new posts are uploaded in ...
MattE's user avatar
  • 101
0 votes
1 answer
90 views

How to change the selected Template using javascript?

I'm using javascript in the editor to look at the content of the post and, if it contains certain strings, change the selected template. Here's a picture of the form and the button behind it. The ...
user18102663's user avatar
0 votes
0 answers
40 views

Force-update the meta variable first set using `var [ meta, setMeta = useEntityProp( 'postType', postType, 'meta' );`

Context: I've got a plugin that triggers some actions when a post is saved, like contact an external API and save the result as a custom field. All of this happens in the background, using PHP and the ...
Jan Boddez's user avatar
-1 votes
1 answer
31 views

Pass global variable data to localize_script

In my template file: product-list-section.php I loop through my products and add data to a global variable: global $product_filter_data; $product_filter_data = array(); // Loop products, grab ...
wharfdale's user avatar
  • 348
0 votes
1 answer
30 views

How can i add a script with parameters?

I am trying to consume the google maps api in a metabox but i don´t know where to add the script provided by the api. <script src="https://maps.googleapis.com/maps/api/js?key=MYKEY></...
mateo ghidini's user avatar
0 votes
1 answer
28 views

What's the best way using vanilla js to force confirmation on publish button?

I am trying to force a confirmation in certain cases in the editor screen. I'm using something like this after selecting the publishButton: publishButton.addEventListener('click', function () { ...
user18102663's user avatar

1
2 3 4 5
53