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

Elementor - retrieving site settings

I've trying to stumble through Elementor developer docs, but I fear that I'm lacking the correct phrasing to find what I need. I'm working on a custom widget for Elementor and I've been wanting to ...
0
votes
0answers
9 views

Redirection after submitting duplicate comment

Sometimes, when posting comments, duplicate comments appear (hosting is very busy ). How do I redirect a post after a duplicate comment is found? At the moment I am forced to use add_filter('...
0
votes
0answers
5 views

php woo echo active price of a variation

i am trying to figure out, how to get the price of the currently selected variable product; neither of these work. they either display min, Max or the html version "from xxx": global $...
-1
votes
0answers
13 views

Add missing image dimensions [closed]

guys! Can someone help me? I have a problem with pagespeed, they said I have 100 images with no attribute width and height. How can I change automatically all images with no dimensions?
1
vote
0answers
19 views

Set and access global variable

I am learning plugin dev and modified this example snippet. I don't get why $myvar is empty in the my_plugin_action_handler function's scope. <?php /** * Plugin Name: TEST Plugin */ global $...
0
votes
0answers
14 views

Add readmore button to excerpt custom HTML

I am trying to display the readmore link in a specific part of my excerpt. The posts are created in a custom plugin, and I write custom HTML as the post_excerpt. However I want to display a readmore ...
0
votes
0answers
7 views

I want to display total-sqft in the end woocommerce invoice template

I want to display SQ-FT total in the end. kindly help me or suggest me the code. because I don't have much knowledge about custom code. Product Unit SQ-FT taking from meta key: Total Area (sq. ft.) ...
0
votes
0answers
16 views

Display metabox galleries on specific page template in admin editor

I'm building a Wordpress website with two metabox galleries displayed only on post type page in admin editor. What I'm trying to do is to display them only for a specific template page in the admin ...
0
votes
1answer
10 views

How can I check if a post with a particular slug or title exists?

I want to know if a particular page exists. I'd like to check against either it's slug or it's title. There is a function called 'post_exists'. But this function seems to only work if it's invoked in ...
0
votes
0answers
20 views

Change variable value when calling function [closed]

I have the following via functions.php: <?php function wp_post_thumbnail() { ?> <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true&...
0
votes
0answers
10 views

tcpd pdfs opening failed

I programmed my own wordpress plugin. One function is to generate some pdf files. First I startet with the following code frome the internet:enter link description here I also used other examples but ...
0
votes
0answers
12 views

PHP function for horizontal Woocommerce thumbnails and badges

I am looking for a PHP-function which checks if the product thumbnail is a specific size (in this case horizontal layout). If so, it should display the Woocommerce-badges (New, Sale, Featured ...) on ...
0
votes
0answers
21 views

Connecting to upstream failed

I have two small sites using the latest WordPress version installed on an Nginx server with PHP 8.0 (FPM). The server has occasional CPU load at random times of the day and the logs show multiple ...
0
votes
0answers
10 views

run wc_get_orders() in none wordpress cron job

I need to run a cron job not using WordPress built in cron functionality. Basically, I need to get all the orders and send some email. I've set up my cron on the server it runs at the desired interval,...
0
votes
1answer
14 views

How do I know if the user is a customer?

I'm using Woocommerce and Dokan latest version. I need to check if the user is a customer of that vendor. In this way, I will show the customer some information about that product or seller. First I ...
0
votes
1answer
24 views

echo something inside a shortcode

I'm a frontender, so i'm not so used to work with php. But I need to solve something. I'm adding a shortcode within the single-product template, and inside this shortcode, I need to echo the slug from ...
0
votes
0answers
8 views

WP Job Manager - connect filter to an existing widget-field

I'm using WP Job Manager in combination with ListingEasy (theme). I have made an extra search filter, based on a new custom form field. However, now I want to refer to an existing field, named: ...
0
votes
0answers
46 views

Saving form with AJAX for WordPress Plugin

I am developing a WordPress plugin that needs to have multiple profiles that the admin can create on the Admin screen. The plugin appends a block to the end of every (unless specified otherwise) post, ...
0
votes
0answers
10 views

Wordpress custom php script to match standard page layout

I am writing a custom php script and want to load the theme so it will look like a regular page. I tried the following. <?php define( 'WP_USE_THEMES', true ); require( $_SERVER['DOCUMENT_ROOT'] . '/...
0
votes
0answers
12 views

Uncaught Error: Call to a member function get_billing_state() [closed]

I have a issues with the function get_billing_state(); Theses is the error: "[05-Jun-2021 18:32:48 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_billing_state() on null in /...
0
votes
0answers
18 views

“Parse error: Unclosed '{' on line 6 in line 23” [closed]

<?php $login_id=$_POST['login']; $pass_word=$_POST["pwd"]; //echo $login_id."<br>"; //echo $pass_word; if($_SERVER["REQUEST_METHOD"]=="POST"){ ...
0
votes
0answers
14 views

Using the get_template_part method within an mu-plugin not possible?

A while back, I had someone here help me craft a custom mu-plugin (aka: "must use" plugin) that was designed to specially handle 404 server responses. Here is that thread for context, ...
0
votes
1answer
28 views

Auto delete empty posts

I'm using IFTTT to post images from a subreddit to my WordPress site, and then WordPress shares those images with their post titles on multiple social sites. The problem is, IFTTT publishes blank ...
0
votes
1answer
12 views

Responsive Button for Mobile

i'm wondering the best way to make these two buttons start on a new line within the header while on mobile. Previously it was just the one button "request a quote" however needed to add one. ...
0
votes
0answers
28 views

Pagination not working in wordPress plugin but working in direct php [closed]

I am building a plugin to fetch and show a lot of data from an external mssql DB, but the pagination part is not working because WordPress won't let me set or update SESSION data using I have ...
0
votes
0answers
15 views

Custom menu - Check if current page is third level sub page

I'm building a custom menu* and I have run into issues with making sure the sub-menu's is expanded when I visit pages 2-3 levels deep. *(or rather I kinda inherited a custom menu and is now asked to ...
0
votes
0answers
9 views

Just show the coupon input filed and button on the checkout page

I want the coupon field on the woocommerce checkout page to be like the image. No toggle button, no dropdown, and no text. Just the input field with a placeholder "Coupon code" and the "...
1
vote
1answer
41 views

Wordpress child theme - adding logo through header.php + text in a footer.php [closed]

I'm confused as to how I add a logo through my copied header.php which is inside my child theme's folder. I'm having the same issue with my footer as well-- in which that the text I'm adding (such as ...
0
votes
1answer
41 views

Convert code - not work

There is a code. add_filter( 'the_content', 'adding_image_dimensions' ); function adding_image_dimensions( $content ) { preg_match_all( '/<img[^>]+>/i', $content, $images); if (...
1
vote
0answers
18 views

Change name of users parameter called 'Roles'

I'm trying to change the name of the parameter of all users called 'Roles' to 'Levels'. I already tried to find it in the database of the website but nowhere this row with parameters was. Is it ...
1
vote
0answers
53 views

Running SMTP Conditionally

I'm working on developing a support website and I'm using Gravity Forms to handle the support ticket form. I have the form notification configured so that the "From" shows my client's email ...
0
votes
1answer
18 views

Fix error Gravatar alt

add_filter( 'get_avatar' , 'alt_name_avatar'); function alt_name_avatar( $avatar ) { $alt = get_comment_author(); $avatar = str_replace('alt=\'\'','alt=\'Avatar for '.$alt.'\' title=\'Avatar ...
0
votes
0answers
11 views

Error in suggestion in search area

I have a problem and I need help. On my website I customized the search area. I let it display only the categories I chose using the category ID. Example: Let's say I have 10 categories on the entire ...
0
votes
0answers
66 views

How to insert ads after an “h2, p, h3, etc…” tag [closed]

This code below is well known on the internet, I tried several times to change it and make it not only count the </p> tag as a paragraph, but the </h2>, </h3>, tags. Does anyone have ...
1
vote
0answers
30 views

How to Add Extra Search terms with Wordpress Search keyword term?

Using the default WordPress search box, when we search for a term, it will result the URL as follows. Search term: hello URL: yourdomain.com/?s=hello I want to add some extra text after the search ...
0
votes
0answers
10 views

Overwrite files once the database reaches a specified number of posts

Hello I am making a system in php in which there can only be a limited number of images in the database and when someone uploads new photos, the old ones will be deleted from the database. I currently ...
1
vote
1answer
34 views

Hide a div when tags doesnt exist [duplicate]

I'm new to php and struggling to find out how to hide the div if there are no tags on the page. This is my code: <div class="etichete"> <p><?php the_tags(); ?></p> &...
0
votes
0answers
13 views

How to only display the third product category child level from one parent of the current Product? - WooCommerce

I would love to find the answer to this one! My WooCommerce Product Category Tree looks like this: Domaines -Domaine1 --Cuvee1 --Cuvee2 --Cuvee3 -Domaine2 -Domaine3 Vins -Rouge -Blanc -Rosé Cépages -...
1
vote
0answers
18 views

Strict Standards Problem after updating wordpress version : Walker function [closed]

I am having the following issue on my Wordpress website Strict Standards: Declaration of AMW_Related_Sub_Items_Walker::walk() should be compatible with Walker::walk($elements, $max_depth, ...$args) ...
-3
votes
1answer
102 views

Are WordPress & PHP objectively and based on evidence going to die because the future is made of frontend rendering instead of server side rendering? [closed]

A friend called Pablo told me to learn WordPress CMS but another friend called Lucas told me to learn Strapi CMS because server side rendering and PHP in general are dying in favor of frontend side ...
1
vote
1answer
39 views

meta_query search names when they have middle initials

I have to build a search form where I search members of the company by their Full Name (First Name + Middle Initial + Last Name). All the names are in this form: John B. Doe The below code is working ...
1
vote
0answers
9 views

Woocommerce rewriting custom price display? [closed]

I'm having an issue changing Woocommerce product archive / shop page pricing display. We're (still) using Woocommerce 4.8.0 and WordPress 5.7.1. Here's what I am trying to do... This shop carries ...
0
votes
1answer
34 views

copy fields value to another field

I've make a custom field named "Phone" using buddypress xprofile plugin, but this field cannot be searched by Wordpress primitive searching engine, I found another field which is "...
0
votes
0answers
10 views

Wordpress permalink, show a product catagory page on a normal WP page

I'm not sure if I'm having a bad brain day but I am going round in circles with something I know is so simple. As a note, I am pretty new to developing in WordPress so apologies if it genuinely is ...
0
votes
1answer
27 views

HTML Special Characters in URL string [closed]

I am using this code to convert the & to its html entity but it doesn't work. The output is passed to a field in gravity forms. <a href="/enquiry/?event=<?php $urlst=get_field('fl_name')...
0
votes
1answer
27 views

how to save checkbox data for custom setting?

I am creating one custom setting panel, my codes are function custom_text_field_html(){ $text = get_option( 'homepage_text' ); printf( '<input type="text" id="...
1
vote
1answer
34 views

How can I get content inside one shortcode to another shortcode?

I have 2 shortcodes, [ref] and [references]. I need to get the content inside the [ref] shortcode and output it when the [references] shortcode is called. For an example; INPUT - This is some content ...
0
votes
1answer
42 views

Remove /category/ from category (archive) page URLs (without using a plugin)

A Category page URL structure looks like this: example.com/category/cat/child_cat/ How can we do: example.com/cat/child_cat/ Without the use of a plugin (eg, Yoast)?
0
votes
1answer
14 views

How to remove sidebar primary widget on Mobile on category page [closed]

Hello i have been trying to figure out how i can hide the sidebar only on Categories page on Mobile I tried this code: @media only screen and (max-width: 900px) { .sidebar { display: none; } ...
0
votes
1answer
19 views

Php string not working in Wordpress Functions.php [duplicate]

How to pass the following code. <div> <?php $category = get_the_category(); ?> <a href="<?php echo get_category_link($category[0]->cat_ID); ?> "> <?...

1
2 3 4 5
192