Questions tagged [php]

For questions about the server-side programming language that the WordPress core, plugins and themes are written in. Questions about using PHP outside a WordPress context are off-topic but might be asked on Stack Overflow.

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

Getting an error when my plugin is updated, but the files update correctly

I have a plugin that I am using GitHub to manage my updates through the GitHub Releases feature. Since this is a private plugin I can't put in up in the Wordpress Plugin Directory. The plugin ...
0
votes
0answers
8 views

Add meta noindex to post if it has a specific taxonomy

How can I add the following line to the current post if the product_type = 'enviso_group_ticket'? <meta name=”robots” content=”noindex,nofollow”/> product_type is a default taxonomy of the ...
-1
votes
0answers
15 views

I am trying to replace DROPDOWN SEARCH FIELD with KEYWORD SEARCH FIELD. My dropdown Search by City is not effective due to huge amount of cities

I need to replace dropdown search field "Search by City" with keyword search field "Type City". Dropdown search is not effective due to over 30 cities. Keyword search will be much ...
0
votes
0answers
8 views

Retrieve some post which match a specific taxonomy and print their url and some relative taxonomy/field in a file?

as specified in the title I should create a (php?) file to upload to the server that retrieves the url of the posts that correspond to a certain taxonomy and simply print the url of these (and some ...
0
votes
1answer
4 views

How do I populate custom field with current user role in Woocommerce

I am trying to populate a custom field called Customer Type in checkout with the current user role. I tried the below in my functions.php of my child theme and thought it would work but it does ...
0
votes
0answers
7 views

Change Custom Post Type Permalink Structure [duplicate]

I want to change Custom Post Type Permalink slug order: From: example.com/cpt-slug/post-name To: example.com/post-name/cpt-slug Does this possible?
0
votes
0answers
20 views

Change the URL of an image from wp_get_attachment_image_src for Product Posts based on Category

I would like to change the URL of an image from wp_get_attachment_image_src for Product Posts based on their Category, for example: If a product post is in product category 1, this will be it's image ...
0
votes
1answer
8 views

Issue in displaying the ongoing event and current events in the post

I am developing a consultancy website which has event to it. I am using ACF for generating event Firstly the event consists of 3 things, Past Events Ongoing Events + current events + upcoming events ...
1
vote
1answer
18 views

Change the URL of an image from wp_get_attachment_image_src except in the frontpage

This is the code I used that is working, but I want it to work only on product posts and not on the frontpage. function alterImageSRC($image, $attachment_id, $size, $icon){ $image[0] = 'http://...
0
votes
0answers
6 views

Wordpress redirect from URL with BuddyPress

I am using the plugin BuddyPress on my WordPress site and when the user clicks on their profile they are redirected to the URL "/members/USERNAME/profile/home/". However, I do not want this ...
0
votes
0answers
6 views

how to display value of acf field from selected elementor control

I have created elementor SELECT control that shows all post from 'post_type' => 'digital_card' now I want to display the ACF field from the selected post my ACF field name is business_name $...
0
votes
0answers
6 views

I want to set multiple selected option( taxonomy terms ) values to database of a custom post type - taxonomy. It is only saving one value

My current php code is as below <?php //Select Paper Colour $paperColours = get_terms( array( 'taxonomy' => 'papercolour', 'order_by' => 'slug', 'hide_empty' => 0) ); ...
0
votes
0answers
7 views

How to create a custom config file and get data using inline JS in a wordpress page

I'm totally new in WordPress as well as in PHP and making my first application with it. Currently, I use 'HTML block Element' to add content with custom HTML and inline Javascript code on blank ...
-1
votes
0answers
11 views

Hide shipping methods for specific shipping class in WooCommerce [closed]

I tried combine, slug and array from this and this question, but have some problem. add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_shipping_class', 10, 2 ); function ...
0
votes
1answer
8 views

WPML best page selector with php

I have a multilingual website made with WPML. I have php code to run across pages but I cannot uniquely target the page with is_page(ID) since the ID of the page changes across language domain. I need ...
0
votes
0answers
9 views

Duplicate an elementor Post via API

I have a special context right here ! I'm using a java App to manage data. My main goal is to use the wordpress to display information, and use the app to work with data. What i'm trying to do right ...
0
votes
1answer
11 views

A server-side hook failed when committing plugin code to SVN

We're trying to commit and push our initial release to the SVN repository assigned to us by the wordpress team. However when committing the code we're getting an error (probably because of the PHP8 ...
0
votes
0answers
30 views

How to disable send e-mail notification new comments for some posts

How to disable send e-mail notification new comments for some posts Sorry for my English
0
votes
0answers
9 views

How can I get the Second Value from a list of three

I have a short code in my theme's functions.php which fetches the city, state and country submitted by users. Using the code which is below, I want to get and display just the STATE only. function ...
0
votes
0answers
7 views

Woocommerce logic of hide payments and shipping method based on shipping classes

Found something similar to what I need here and here but there were difficulties in combining and building the correct logic. In the screenshot below you can see what kind of logic I wanted to set.
0
votes
0answers
7 views

Give Woocommerce Customer permission to create order [closed]

I am developing a mobile app that uses a Woocommerce back end. For user authentication i installed the JWT plugin and got it working so far. Creating orders works but only when i let an admin create ...
0
votes
0answers
14 views

How to display Woocommerce cross-sells in single product tabs [closed]

I'm trying to display cross sells using the following function: woocommerce_cross_sell_display(); This function is part of Woocommerce default functions, and it suppose to work. Meanwhile I receive ...
0
votes
0answers
14 views

I have a wordpress site on cpanel but my .htaccess file displays my hosts “coming soon” page instead of my website. how do i change this? [closed]

I have a wordpress site on cpanel but my .htaccess file displays my hosts "coming soon" page instead of my website. how do i change this? Below you'll see my file structure on cpanel. My ...
0
votes
1answer
26 views

Custom shortcode for displaying user based on a role parameter

I've created a plugin that with a shortcode displays all users with the custom role "ansatt". This works perfectly fine, but I'd like to be able to set the role as a parameter within the ...
0
votes
1answer
17 views

WP custom posts: filter results to custom taxonomy tag that corresponds to user meta field

I need some guidance on making a wordpress posts query responsive to user meta data, and whether it’s possible to do what I want within the query itself, or if further work is needed in the database ...
0
votes
0answers
19 views

Capturing variable after slash in domain

I'm developing an ecommerce website with Wordpress / Shopify API. I'd like to be able to capture discount codes through the URL. So if the discount code was code40, I'd like the enduser to be able to ...
0
votes
1answer
26 views

If is_page include/else not working all of a sudden

I've had the same code on my wordpress site for more than a year, and it's stopped working. This is part of page.php: <?php if (is_page( 83571 )) { include('adsense-schools.php'); } else { ...
0
votes
0answers
19 views

Update Images after edit via php

After editing images directly inside the upload folder via PHP-functions, I managed to automatically regenerate the meta data, the thumbnails and the WebP copies. (Checked via FTP! Even the displayed ...
0
votes
1answer
10 views

trying to put an active hover to my custom nav category buttons

I have a custom category buttons which each of buttons link and echoed the specific category at the same page. my goal is to put a active background hover color on the active link. here is my code so ...
0
votes
1answer
15 views

Search WordPress using static html page

So I have a .html page under my Wordpress website and I want to be able to use the search button on the static html page to search the search.php page, is that possible? Is this correct? This is ...
0
votes
0answers
13 views

Cant create table on plugin activation

I am trying to create table on plugin activation, I tried making the same function inside the class and calling it from the constructor, and I tried calling it outside the class and finally i tried to ...
0
votes
2answers
39 views

How to edit HTML of my website on WordPress?

There's a few parts of my website where I'd like to edit the HTML code. How to edit the HTML code of my website without the edits getting wiped out after an update? I've heard about child theme's but ...
1
vote
0answers
15 views

Embed html in php code

I am not following the PHP OOP as of yet. I have one main plugin.php file, which contains the main class of my plugin. This is where, I enqueue javascript file (plugin folder/assets/plugin.js) , which ...
0
votes
1answer
22 views

Variant Item SKU as Product Code

I am working on a new website for my company. We have products with variations. each variation have its own SKU number. When we select the product, the correct item is displayed in the cart with ...
0
votes
1answer
42 views

Use wp_head hook on template page

I try to use the hook wp_head on a template page but this does not work add_action('wp_head', 'to_head'); function to_head(){ //do stuff } I placed this code on a template part what is called by ...
0
votes
1answer
10 views

Redirect first comment (Thanks for comment) with show Autor name and beginning of the comment

Redirect first comment (Thanks for comment) with show Author name and beginning of the comment Sample: Open custom page (Why custom page? There will be some more information) with text comment Hi, ...
0
votes
0answers
18 views

Combine change Email Wordpress and woocommerce emails template

I use this plugin for customize woocommerce emails. But unfortunately I found out that it does not change the standard Core Wordpress emails. For example if client want change email in account details,...
0
votes
0answers
19 views

WP-Citical Error on your site [closed]

I'm getting critical error message on one of my page. What weird happens is that when I turn on debugging, it works fine although it show some warnings and notices but no fatal errors. When I turn off ...
0
votes
1answer
14 views

Run PHP 24hrs After Event Trigger

I'm a bit lost on this one and would appreciate some direction. I have created a plugin that sends a message to a user after they successfully sign up. However, I would like this message to be sent 24 ...
1
vote
2answers
28 views

add_meta_box (Will display only in specific page admin WordPress)

I am wondering how to add meta box in WordPress specific page admin, I mean when I create meta_box with code snippet below provided from source tutorial is really perfect and effective but one thing ...
0
votes
2answers
26 views

Large Wordpress CRON job

I'm programming the integration with external API (real estate). I have one CRON job which is planned for at 1 o'clock am. It's running very well because I'm using server CRON initialize instead WP ...
1
vote
1answer
12 views

Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?

I currently have a Portfolio custom page in Wordpress, so far work as i want, but i have one problem. The problem is when i click one of the button slug then the body/output is not work like i want, ...
1
vote
0answers
17 views

How to programmatically add Gallery Block to Existing Post Content

I need to insert a set of images already in the media library to the end of the content of each new post. Instead of inserting the html directly is there a way to add a Gallery block by using the ...
0
votes
0answers
39 views

When I click for the redirect link it is showing the content of index.php instead of single_assignment_page.php

When I click on a link to redirect to 'single_assignment_page.php' it is not showing the content of this page but it is showing the content of 'index.php'. That's something I don't want but in the URL ...
0
votes
0answers
15 views

Ajax result show in console if is called outside function and not showing in array

In wordpress theme I must change custom functionality and use ajax, so I have dropdown and on change I grab selected option: JS $( ".select-class" ).change(function(e) { var ...
0
votes
0answers
20 views

Replace jQuery with PHP or CSS for Customized WordPress wp_nav_menu

Does anyone know how to build a custom wp_nav_menu layout without using jQuery? My current menu loads fine, but it causes the whole page to shift. jQuery adds CSS classes to items in the menu after it'...
0
votes
0answers
9 views

How to make a front end fields from metabox

I want to clarify that I am not a specialist, my query is how to insert a metabox in the front end, specifically I show you the image: I want to do this: But actually I have this: Those are the php ...
0
votes
0answers
16 views

How to define a variable and use it in shortcode?

I am new to wordpress development as well as php and html programming and I need some help with something. I would like to get the title of a bbPress topic and then store that in a variable. Then I ...
0
votes
0answers
13 views

Woocommerce add products to cart

Is there a way to add a product to woocommerce cart without passing the product ID? So I have a DB with products and I do not want to import these products to woocommerce products in backoffice. Can I ...
2
votes
2answers
25 views

enqueue hover function

I am trying to enqueue a hover function in my functios.php of my child theme, so that when hovering over a title, a div with a text will be visible. The code I am using is this: <?php add_action( '...

1
2 3 4 5
191