Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
7 views

WordPress Media Grid - not loading pictures

The following page contains 2 media grid sections. The media grid under title: Finishes is not loading. I only see animated loading dots but the pictures won't load: http://acdwheels.com/brixton-...
0
votes
0answers
13 views

Tell wordpress to show a single page instead of an archive page

my wordpress site urls like this: https://example.com/?pid=a125a5&lang=en and query of my archive page like this: <?php $the_slug = get_query_var('pid'); if ($the_slug){ if ( $post = ...
0
votes
2answers
11 views

WordPress filter from custom table is not working properly

I want to filter the exact information from a custom WordPress table no matter the user has filled all the text boxes or not. I have used a LIKE query but it`s not working properly if the user left ...
1
vote
1answer
13 views

Add to checkout total lines an additional line below shipping in WooCommerce

I need add "Include pack" line with conditional logic to WooCommerce checkout review order section. How it possible?
0
votes
0answers
12 views

how to make Wordpress DB lookup code to do “if” funcation

I have a wordpress website that using WPUM to creat accounts and mange them and a coustem plugin for memberships. When users creat an account they chose from membership plugin membership kind ( Sun - ...
0
votes
1answer
40 views

Reason to add a name of the theme like ('menu-1' => __( 'Primary', 'twentynineteen' ),) in PHP?

Sorry for this novice question. I'd like to know why WordPress themes add their theme names many occasions in PHP files (e.g. where 'twentynineteen' is repeated below, this is from functions.php in ...
0
votes
0answers
6 views

Primary navigation menu with timed items from custom post type

I have created a site (livermorevalleyopera.com) for a client. I made a custom post type for events. In the primary navigation I have a top level menu item "Season Events & Tickets" and the ...
0
votes
0answers
18 views

How to override WooCommerce Order Item Meta with data from Cart?

I have the following function that is overriding some of the values that are saved to the Cart and Checkout, via the YITH Bookings plugin. Essentially, I have overridden the Duration field with my own ...
1
vote
1answer
14 views

Change the displayed shipping total in WooCommerce

I need to change shipping price programmatically: <?php $percentage = 50; $current_shipping_cost = WC()->cart->get_cart_shipping_total(); echo $current_shipping_cost * $percentage / ...
0
votes
0answers
10 views

Convert any video formats to MP4 - PHP/WordPress [on hold]

As except MP4 format, browser is not supporting other formats. I have heard about FFmpeg but how it works in my localhost that doesn't know! So is there any plugins or any library available that ...
0
votes
0answers
10 views

gallery with post category and custom fields

I'm trying to create a YouTube gallery where i use Posts to get info of the iframe and Feature image. I've built the following gallery: <?php global $post; $args = array( 'posts_per_page' => -...
1
vote
0answers
9 views

How to bypass maintenance mode with external cron?

I'm using crontab to run a php script loaded with wp-load.php with absolute path. However, when I go to maintenance mode, the file can't run. I'm using Coming soon plugin. Is there a way to exclude ...
0
votes
1answer
7 views

Woocommerce: Display an image on Products from a Specific Category?

Does anyone have code that can be added to functions.php that will allow me to display an image only on products that belong to a specific category? Preferably I'd like it to display over top of the ...
0
votes
1answer
12 views

HTML tags in bloginfo description

I'm trying to set some <span> tags in the bloginfo description. So I put this in the blog description field: <span class="name">Archive | Navarro Vives</span> <span>is a point ...
0
votes
2answers
17 views

Custom post type category not displaying category ID

I'm trying to get the category ID so I can call a loop query on only that category ID. However the following code returns null. Any ideas why? In the admin bar it shows edit category with an ID of 3, ...
0
votes
0answers
7 views

Redirect user after form submit alert message

I need to display a javascript alert after a form submission and then redirect the user to the home. I have this code, but it will always redirect the user to the wp-admin/admin-post.php page. How I ...
0
votes
1answer
33 views

How do I wrap this?

I have snipped of PHP code I'd like to have wrapped within its php-file with the do_shortcode function. Unfortunatly, I don't have clue how to do this. Several ways I tried end in an error on the page....
1
vote
1answer
19 views

Which field should I edit to make the checkbox marked by default?

I have a php form that I want to change the state of a checkbox so it's filled by default, but there are two fields that may be the right way: 'request_vendor_access' => array( '...
0
votes
1answer
17 views

Get first URL from post content

Basically all I want to do is if the post format is "link" rather than link to the post from the blog index, link to the link pasted within the post content. In my index.php I have: <h3> <...
0
votes
0answers
14 views

I want my category (archive) pages to mimic the structure/style of my Posts (home) page

Theme I'm using is easymag-pro. I will paste both pages below. I know I have to replace the archive.php with my home.php, but I need to add something to the new archive page so it will pull the posts ...
1
vote
1answer
23 views

Display a selected custom product option in WooCommerce cart

I am using the code below to display a custom select field on WooCommerce single product pages: <?php $sizes = $product->get_attribute( 'size' ); $sizes = explode(", ",$sizes); ?> <?php ...
-1
votes
1answer
17 views

how do integration Carousel on Wordpress?

Get help from you how to place Carousel in this code that I have now: <div class="black"> <section class="t-grid-11"> <div class="t-grid-i"> <div class="t-grid-i-i"> <...
0
votes
0answers
7 views

503 Server Error Code [on hold]

Hi I would like to ask regarding my error I get. The problem solve after I increse the MAX_EXECUTION_TIME & MEMORY LIMIT . But after a few days the problum occur again which I need to increase and ...
0
votes
1answer
28 views

Return author name as a tag using get_author

I'm trying to display the author name as a tag. I looked at many forums and it's referring to the get_author methods and the PHP files from the template PHP. However, I do not know what changes to ...
0
votes
0answers
11 views

How to save and retreive an array from checkbox list in Theme Options [closed]

I am developing a very simple WP theme and I wonder how could I get this functioning. The main goal is to save the value of the selected checkboxes and retreive it in the front-end footer to load the ...
2
votes
1answer
30 views

Get WooCommerce product details and transfer them to a custom DB table

I'm currently doing a registering service for products with WordPress and WooCommerce. All products that customers can register will be in the WooCommerce database, but not visible on frontend. Here ...
0
votes
1answer
19 views

How to add a new column with text fields to WooCommerce Cart List?

As attached images. How to add a new column with text fields to WooCommerce Cart List? Thanks.
0
votes
0answers
11 views

Is it possible to create a toggle session() using <a> tag or button [closed]

I have an intention to create a toggle button in my web page.Usually, I am using GET_ method. But, just for an excitement, Is it possible to create a toggle session() using a single <a> tag or ...
0
votes
0answers
48 views

Move plugin upload folder from mywebsite.com/wp-content/uploads/pdfuploads to mywebsite.com/pdfs?

I'm currently using a plugin that generates a PDF for customers but the URL is way too long. For eg - https://www.mywebsite.com/wp-content/uploads/pdfuploads/666666.pdf. Here's the specific code from ...
-1
votes
0answers
15 views

How do I make a div a specific size when doing an image gallery?

I am making a new custom plugin for my WordPress site that displays an image gallery using the shortcode: [galleryplugin] The plugin uses PHP and JavaScript. Essentially I want the shortcode to ...
0
votes
2answers
25 views

Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test

I've been trying to grasp AJAX for the past 12 hours and i'm slowly losing it. How can I simply pass two basic input dates via form or any other means, not refresh the page, and have it execute the ...
0
votes
0answers
28 views

Ajax load more posts with Ajax taxonomy filter

I'm trying to create taxonomy filter with Ajax load more posts, everything is working except the first page on my template! I have a custom template page for taxonomy downloads as below the load ...
0
votes
0answers
13 views

How can I add links to posts and pages using a particular image from its own media attachment page?

I have various media attachment pages e.g. https://www.artobatours.com/rock-art-abric-del-mas-den-ramon-den-besso-muntanyes-de-prades-catalonia/ where I have the image and some exif data. Along with ...
1
vote
1answer
17 views

Make specific products accessible only to a user role in WooCommerce

I am making a plugin to hide specific product category only for a user role. add_action( 'woocommerce_product_query', 'wcpp_hide_product' ); function wcpp_hide_product( $q ) { //if main query, ...
0
votes
0answers
22 views

How do I edit the text in this function.php file?

How do I change the text "This comment was edited." in this function.php? <?php if ($edit_comment == "edited") {?> <em class="comment-edited"> <?php if (isset($its_question) &&...
2
votes
1answer
20 views

Get product attribute for Simple product in WooCommerce

I need to get product attributes from product in WooCommerce, type product Simple product, some product can be as dropdown, but much options as radio button. How I can do this? How it possible? ...
0
votes
0answers
8 views

Apply a different filer and parse the entire document instead of just the_content

Good morning, I'm trying to modify a plugin, to lazy load my images (a3 lazy load). The problem is that this plugin is returning only the images in the content, but for some reason when we created ...
0
votes
1answer
16 views

Exclude posts with specific metadata from search?

I have created this searchfunction that looks like this: function search_data_fetch() { $search_query = new WP_Query( array( 'posts_per_page' => -1, 's' => esc_attr( $_POST['keyword'] ), '...
0
votes
1answer
10 views

How to pull date/time in french format for wordpress post?

I am working on a wordpress post in which I want the date/time in frech format as shown below: ENGLISH By FJ Published April 9, 2019 at 4:05 p.m. Last updated April 9, 2019 at 4:14 p.m. FRENCH Un ...
1
vote
1answer
25 views

Query WooCommerce orders grouped by several order statuses

As I can see from WooCommerce documentation, WC_Order_Query allows only one single order status to be passed as query parameter. Has anyone find some workaround to allow querying several order ...
0
votes
0answers
8 views

how can i get previous $_GET? [duplicate]

i want to save previous $_GET and get it in the next refresh. then use it to see if it has been changed or not. i want to do it because is i change may form and go to next page, in the next page it ...
0
votes
1answer
28 views

Call to undefined function get_userdata() in plugin

After refactoring/restructuring files in my plug-in, I now get the error Uncaught Error: Call to undefined function get_userdata() after code $current_user_id = get_current_user_id(); $...
1
vote
1answer
15 views

Woocommerce: Is it possible to overide the settings for allowing to purchase out of stock products

So, like the title says, I am looking for a way to override the setting that makes a products that is out of stock not purchasable. I know I am supposed to use the "allow on backorder" setting to do ...
1
vote
2answers
30 views

Missing Author Information

I am having trouble displaying the author name and avatar on my single.php page. The posts load fine and all the correct information is available. However the avatar and name is no where to be found. ...
0
votes
2answers
17 views

Path for php file for inserting data through html form

I have a HTML form which inserts data into a custom table. The code for inserting the data is in a PHP file . My question is where do I place the PHP file in the WordPress filesystem? I have tried ...
0
votes
0answers
13 views

How to properly add custom product meta to order meta in woocommerce

I have the code to add some custom product meta data to cart and then later pass them to order meta. Everything works fine but it feels like the add to cart process is quite slow which makes me wonder ...
1
vote
0answers
18 views

Add filter when image is uploaded?

I'm trying to use this code from another SO resopnse: function ajx_sharpen_resized_files( $resized_file ) { $image = wp_load_image( $resized_file ); if ( !is_resource( $image ) ) ...
0
votes
0answers
10 views

Filter for widget media image

There is a filter for "widget_media_image"? I'm trying to add new attributes using preg_replace but i can't find the correct filter for this widget.
0
votes
1answer
35 views

change title page on search result

I want to change in my search result the title. Unfortunately I don't have option to change this in , because I must do it in plugin file. Actually I have that code in PHP file: if (isset($_GET['...
1
vote
4answers
239 views

get_users(…) only returns one user

I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, get_users(...) ...