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

How to extract RSS Data with g prefix

I have the following RSS I am not able to get the item tiles with g prefix <g:title>Co with the flow</g:title> but if I just use <title>Co with the flow</title> it's working ...
0
votes
0answers
8 views

Order by title Child Pages displayed in a Parent Page

I am using the code bellow to display a list of Child Pages on a Parent Page. I want to order the displayed list by Alphabetical order. How can I achieve this? function wpb_list_child_pages() { ...
0
votes
0answers
9 views

I want to add a custom select field in a WooCommerce Checkout - and based on the selection, open new text fields to be added

add_action('woocommerce_before_order_notes', 'wps_add_select_checkout_field'); function wps_add_select_checkout_field( $checkout ) { echo '<h3>'.__('Delegates').'</h3>'; ...
0
votes
1answer
14 views

str_replace with the_content is not working [closed]

I am trying to replace the a URL of the content with php. i tried the code mentioned below but it didn't work. is there any way to achieve this with php only? function replace_text_wps($text){ $...
0
votes
0answers
9 views

Text not rendering on iOS

Here is the site in question. If you are on iOS then scroll down until you see a "telephone" section, there won't be a number underneath. This doesn't happen on computer. I can click on it ...
0
votes
0answers
22 views

Reading URL Parameters

The following URL call, is redirected and processed by the 404.php page, indented to capture the s parameter. https://www.example.com/doc/?s=par For some reason, while try to processing the s ...
0
votes
0answers
10 views

Unable to hit hook with form submit build with “wp_ajax_{$action}”

I'm all I'm currently trying to build a hook using do_action( "wp_ajax_{$action}" ) on a Form submit. I built the following form. <div class="layout-gutter bg-grey-lightest p-4"...
0
votes
0answers
8 views

What do I add to specificy another category for a custom header?

This is current code, I'd like one more along the lines of elseif ( is_category('new-header-cat') || is_single() && in_category('new-header-cat') ) : <?php else: ?> <div class="...
0
votes
0answers
6 views

divide the editor text which have html attributes on every 500 th character length for creating text slider

I have to create the text slider , but that text have html attributes also,so supposed i have 1000 char length of text including html attribute and if i am dividing the text on every 500 character the ...
0
votes
0answers
8 views

How do I create auto open and close alert push notification on WordPress site?

I am developing auto alert notifications on WordPress loop posts. I am looping posts using while loop and displaying on alert at time intervals. Now I don't know what do I do in order for me to loop ...
0
votes
0answers
6 views

Wp-rocket indexing single page as home page>>>Why? [closed]

I am having issue with WP-rocket plugin if activated it will index and single page and set as home page? why? how i can resolve this issue?
0
votes
0answers
11 views

Include User ID in iFrame URL

I seem to have hit a roadblock trying to figure out how to append the user ID to an embedded iFrame url address. I am using a third party app that tracks unique users (and invoices me accordingly). ...
0
votes
0answers
15 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
18 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 [closed]

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

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

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
22 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
20 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
7 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
7 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
10 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
12 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
10 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
8 views

Woocommerce logic of hide payments and shipping method based on shipping classes [closed]

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
8 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
15 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
15 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
28 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
20 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
16 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 ...

1
2 3 4 5
191