Questions tagged [functions]

A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.

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

Wordpress if (is_page) translation on certain page

Hy there i have the following code for custom translations there are missing. function translate_text( $translated ) { $translated = str_ireplace( 'All Ratings', 'Alle Bewertug', $translated ); $...
0
votes
0answers
8 views

Multisite redirect upload path from server 2 to server 1 with haproxy

I have 2 servers with Wordpress MultiSite installed. I also have a server with haproxy installed. haproxy server: 10.10.10.10 site - 1: 10.10.10.11 site - 2: 10.10.10.12 All requests coming to the ...
1
vote
1answer
8 views

Display a specific category of products in shop page and disable code for specific actions

I want to display a specific category of products on the top page of the shop page. This was achieved with the code below. However, with this code, when searching for products from the search console, ...
1
vote
0answers
10 views

WordPress Menuing Question :focus

I'm using the following script in the WordPress functions.php file to disable top level parent items when they have a submenu. It works perfectly, but I need to it actually work like this: If ...
1
vote
0answers
12 views

IF Statement on Button to make it complete and “uncomplete” based on user action / click

I am just working on an LMS and there is a php if statement, that from as much as i can read, says if the button is clicked return this state e.g. set the button and lesson as Completed (default state ...
1
vote
0answers
9 views

Create a new query in function.php to filter blog posts

My goal is to filter blog posts (those which are requested in the blog page - Reading settings) depending on an expiration date, and then to change their category depending on a choosen future ...
0
votes
0answers
18 views

how to make a calculated fields in ACF

i want to create a field for average rate with other fields All fields are in one field group For Example field1 = 70 field2 = 60 field3 = 80 field4 = 0 field5 = 0 field6_total = 70 im tried with ...
1
vote
0answers
22 views

Woocommerce related product text

Hi guys im currently using this in my function.php // Change WooCommerce "Related products" text add_filter('gettext', 'change_rp_text', 10, 3); add_filter('ngettext', 'change_rp_text', ...
1
vote
0answers
10 views

How to add SVG icon above product tab title

I used the following code to create custom product tabs (woocommerce), and now I was wondering if I can add an SVG icon above the tab title. My code for a custom product tab: add_filter( '...
0
votes
0answers
18 views

prepend and display custom header widget area

so in my functions.php i have a hook as per theme documentation in prepending content before the body. i also create a widget area, which i'd like to be the prepend content, as follows: // create ...
1
vote
0answers
12 views

Filter out other users comments. Visualize only own comments and editor role users' comments

I have a similar request as per question but I am totally not into php and would not know where to start to make such edits based on the answer provided. Would be great if anyone could help here. ...
1
vote
1answer
25 views

Get Current Page ID in functions php, meta query filter

How do I get the Current Page ID in functions php when creating an meta query filter? I've made many attempts but all return Null. The filter works as expected when I manually input a number, but I ...
1
vote
1answer
17 views

Gravity Forms Button Text

I am creating several Gravity Forms that use a button instead of an input to submit. I got the button working, but I was wondering how I can use the button text in the admin panel, instead of hard-...
-2
votes
1answer
13 views

Can't modify plugin function

Is there any possible way that could help me overwrite or redeclare a function inside a plugin? I tried to create a folder with its name inside the child theme, but it did nothing. The original path ...
1
vote
0answers
39 views

call of javascript function to external url always blocked by cors

I created a javascript function that have to be called every time someone clicks a button. This is the code present on file /wp-includes/js/utm.js: function event_click() { document....
0
votes
1answer
43 views

Allow user only create specific tags

I am using an editorial wordpress theme that has a frontend post editor for a user (contributor) to create a post. The editor is giving permission to the user to choose category for the article and to ...
1
vote
1answer
7 views

How to properly remove style for non logged in and front page only

I am trying to remove style for non loggedin user & front page only. i am trying this but didn't work. any idea where i am making mistake? add_action( 'wp_print_styles', 'my_deregister_style', ...
1
vote
0answers
12 views

esc_html_e() is not translating string in wordpress [closed]

I am using esc_html_e() function as shown below to translate a string. <h1><?php esc_html_e('Question', 'abcd'); ?> &nbsp;</h1> On english page, it displays the right word ...
0
votes
0answers
6 views

ACF gives “Validation failed. 1 field requires attention”, while everything seems fine

System Status: Advanced Custom Fields Version 5.8.7 WordPress Version 5.3.2 Theme Kunco I am having too many fields on the product page so I have used ACF to create all the fields and mapped them on ...
0
votes
0answers
12 views

Add Custom Variables to Post

i want to add custom variables to WordPress. I want to add Variables via the "Document" Area: In this "Document" Area i want another Dropdown and in this Dropdown there Should be 5 TextFields, where ...
0
votes
1answer
37 views

How To Enable Block Editor (Gutenberg) for Existing Post Type via functions.php

I'm having a tough time figuring out how to enable the block editor for an existing post type in a theme. I'd rather edit this via the functions.php in my child theme rather than edit the theme itself....
2
votes
2answers
25 views

Generate permalinks

I want the permalinks to be like youtube generated from letters and numbers in 9 digits I modified this code add_filter( 'wp_unique_post_slug', 'unique_slug_108286', 10, 4 ); function ...
0
votes
1answer
32 views

is_email gives me error

As you can see on this link: https://cixme.deniz-tasarim.site/video-upload/ after click submit button, wp says me e-mail is invalid but I enter valid e-mail. Array ( [email_valid] => Email has ...
-1
votes
0answers
11 views

In specific page, run function to edit title

I want to execute a function in a specific page only, that edits the post title of posts inside a post-grid plugin. I tried: if (is_page('my-slug')) { add_filter(...); } //page slug if (is_page('...
-1
votes
0answers
16 views

Code to set priceValidUntil to a default value on WP WC scheme wont run, any suggestion?

so I have run google search console on my website and I have a problem on priceValidUntil of the product schema on woocommerce specificly on product -> offers -> priceValidUntil, so I went to check ...
0
votes
0answers
14 views

assign custom author page based on author role

I have 20 different custom roles with several users, many of whom need an author page assigned based on their role. I found here a code that seems to be useful for finding the role of the author of ...
0
votes
0answers
11 views

Default Post Settings

I have recently dived into exploring WordPress and I would be really grateful if someone can clarify what exactly the following options do. Attempt to notify any blogs linked to from the post - On ...
0
votes
1answer
14 views

Update $wpdb query with AJAX

I display a list on my website with a custom database table : $resultats = $wpdb->get_results( $wpdb->prepare( "SELECT photo, nom, prenom, titre_fr, departement_fr FROM {$wpdb->prefix}...
0
votes
0answers
22 views

Trying to change widgets h-tags

I have created a child theme of moesia-pro-ii. The moesia theme has a widget folder with a php file named "fp-latest-news". In default this widget uses h4 tags. I want to change the h4 to h3 tags in ...
0
votes
0answers
17 views

Using a function / displaying the result of the function twice in same page

I have a script showing open/closing times. It is displaying fine when calling the function in my header file. When I try to call it in my mobile menu - CRASH - nothing or errors etc. (depending on ...
0
votes
0answers
6 views

“add to quote” functionality on a non-WooCommerce site?

I have a regular site with over 3000 "products" set up as pages (we are specialty brick and mortar store and don't show pricing online". I am looking to add a quote cart functionality where customers ...
0
votes
0answers
17 views

Auto custom field to category

i use see this script to auto fields to category function wpse_248054(){ $custom_field_name = 'Genre'; $posts = new WP_Query( array( 'posts_per_page' => -1, ...
0
votes
1answer
21 views

only update titles of single posts

The below function wraps all titles of all pages in a * symbol. I want to change the function so that it only applies the filter to titles of single posts. How can I accomplish this? function ...
0
votes
1answer
14 views

Post content overflows on my mobile phone

My post contents (single.php) overflows on my mobile phone so the page is wider than phone's screen. Post Example: http://www.migrate666.deniz-tasarim.site/2020/02/23/work-with-a-team/ I used to ...
-1
votes
2answers
53 views

I want to add the alt attribute to all the photos!

Hello everyone and I found you well, I have a problem with a dynamic site that contains over 200,000 photos, it is a news site. The site is built on the WordPress platform and has many changes to suit ...
0
votes
1answer
29 views

Change menu based on page template via functions.php

I'm trying to swap out the main menu of a page if it uses a specific page template. This was working perfectly until I added a 2nd menu to the page. I would greatly appreciate any guidance on how to ...
0
votes
1answer
30 views

Stylesheet does not load despite functions.php

I am calling my stylesheet styles.css within functions.php. Also adding add_action. But it does not work… <?php function myBlog_files() { wp_enqueue_style('styles', get_stylesheet_uri()); } ...
0
votes
1answer
39 views

PHP 7.1 | Warning: A non-numeric value encountered in

Warning: A non-numeric value encountered in line 107. <div class="like"> <?php $nonce = wp_create_nonce("my_user_vote_nonce"); $likeLink = admin_url('admin-ajax.php?...
0
votes
1answer
21 views

Need php code's output to display underneath a Divi Module

I have functional php code for a page which creates a table. To get the table to display on the front end, I used a Page Template (see code) to create the page (in Page Attributes), rather than using ...
0
votes
0answers
15 views

Use buddypress function outside of plugin

I have a question regarding Buddypress plugin. It seems that I can use Buddypress function such as bp_core_signup_user() without any declaration on other plugins. How is it possible? I’m newbie to ...
0
votes
1answer
35 views

Woocommerce - Check cart for 2 products, remove 1 if the other is in cart

I have a setup where if the order minimum is $100 a free product is added to the cart. If the customer once again goes below the order minimum the free product is dynamically removed via ajax. I ...
0
votes
1answer
18 views

How do I check or test a WordPress Auto Year Change Script?

How can you test a WordPress copyright year that is generated dynamically or through PHP, meaning when the year changes without waiting an entire year to see if it changes? I do not know anything ...
0
votes
0answers
12 views

Use bp_core_signup_user on another plugin

I would like to use the BuddyPress verification email system using bp_core_signup_user function on my sign-up widget plugin. It creates members on my DB but failed to add users to the 'signups' table....
0
votes
1answer
24 views

How to add a button to remove the post from the list of favorite post?

I have created a client's website where I added the functionality that logged in user can mark the articles as its favorite for that I'm using favorites for WordPress plugin. I did this by creating a ...
0
votes
1answer
23 views

Urgent - WordPress keeps creating posts

I was trying to create a WordPress function that altered the post_name. My final function is: function edit_permalink( $post_id ) { if ( 'ratings' === get_post_type( $post_id ) ) { ...
0
votes
1answer
42 views

CPT tags not showing when editing post

Since Gutenberg I've used the plugin "Classic Editor" for one of my websites until I have time to make the necessary adjustments to fully work with the new Gutenberg look. I'm now starting to look at ...
0
votes
0answers
29 views

Exclude category from function - PHP

I have the following code in my functions.php to move product category description to the bottom of the category page. remove_action( 'woocommerce_archive_description', '...
0
votes
0answers
14 views

Live updating Input Field (Number) Value by chaning 3 other input fields

I have three input type number fields as fields in a meta box. They can be filled, they save, they are updated with last inputs and everything is fine. The IDs are: nutrix_preparation_time ...
0
votes
0answers
39 views

Is wordpress overriding the pre-defined scandir function of PHP?

Let's say I have a file: script.php /path/to/example.com/wp-content/plugins/sample_plugin/child/grand_child/script.php <?php $files = scandir('/path/to/example.com/wp-content/plugins/...
0
votes
1answer
42 views

Override the plugin class and function

hope somebody could help me. I have bought one plugin. But I need to change the function of the plugin in my child template functions.php Here is the classes and functions of the plugin. I need to ...

1
2 3 4 5
97