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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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.

2
votes
1answer
1k views

how to update and display an option without reloading the page

Hello I have a select box in which when one item is selected a update_option event fires and get's the selected item's value and echo's it on the page without having to reloading the page. I've put a ...
0
votes
1answer
6 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
8 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
6 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
32 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
2answers
2k views

Setting value of session with Ajax not working

I´m kind of new to using Ajax but I am trying to update the value of a session using Ajax. The Ajax call shoud fires when clicked on a button. When I click on this button it also returns the succes ...
1
vote
1answer
22 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
vote
2answers
958 views

How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field

I have searched high and low for a solution and couldn't find anything; hopefully someone here more skilled than myself can lend a hand. I have two testimonial videos (from a video custom post type) ...
1
vote
1answer
16 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
3answers
838 views

Add URL parameter to all internal links using a specific theme

I got stuck with some modifications and maybe someone could give me some help. What am I doing I use the multiple theme plugin to switch themes for my WordPress project. To switch between the ...
0
votes
1answer
16 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
9 views

Why ImageMagick doesn't work? [on hold]

Last version Wp, clean setup, php.ini => extension=imagick.so exists. Why doesn't it work? add_filter( 'wp_image_editors', 'select_wp_image_editors' ); function select_wp_image_editors( $editors ) { ...
0
votes
0answers
13 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 ...
0
votes
1answer
22k views

Post + form + action + results on the same page

I'm trying to put on a post a custom form and, on the same page I'd like to visualize the results of an action on the form. But I'm missing the basics. Essentially I'd like to do something like this....
-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 ...
1
vote
3answers
9k views

if plugin is active? check if plugin is enabled or not?

I'm using the mingle plugin and the mingle-forum plugin. I want to show a certain part on my site only if those two plugins are active. How can I solve this? <?php if ( is_plugin_active('mingle-...
0
votes
1answer
1k views

How to solve 404 permalink errors on nginx server

I can't solve this issue. I tried everything I found over the web. I first tried configuring my nginx.conf following the example on codex with no success. https://codex.wordpress.org/Nginx I found ...
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 ...
2
votes
1answer
27 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
0answers
11 views

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

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 ...
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.
1
vote
1answer
480 views

Executing my function once on a specific time

On our WordPress website we are using the Events Manager Pro plugin. This allows us to create events. However we need to somehow send a thank you E-mail to the attending people 1 day after the event ...
0
votes
0answers
47 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
20 views

How to know find the input id for use it on wp_insert_post

I made wp plugin for automatic posting require 'crawel.php'; if (isset($_POST['activated']) && is_admin()){ $new_page_title = $manga_name; $...
1
vote
1answer
372 views

Add a class to the anchor tag on HTML5 gallery

I want to add a class to the anchor tag of the HTML5 gallery, so I can use a lightbox plugin, but I do not know how to do that, i've tried with the code below, but without success. add_filter('...
0
votes
0answers
11 views

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

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
2answers
24 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 ...
1
vote
1answer
53 views

Replacing a plugin function with a custom renamed function doesn't work

With WooCommerce and WooCommerce Bookings plugins enabled, I am trying to add a text line above the product time picker section to advise the customer that they need to select one of the options. I ...
0
votes
1answer
382 views

How to translate wordpress error message

I have a problem and I am not finding the variable to solve, I have a site in WP and when I try to login and neither the password nor the email exists, I get the error message: ERROR: The username or ...
-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 ...
1
vote
1answer
38 views

Woocommerce get selected shipping zone id for the current user

How can I get the selected shipping zone id based on current user in WooCommerce? I tried the code below, but I didn't get the zone id from the cart page: $bh_packages = $cart->...
1
vote
1answer
16 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, ...
1
vote
1answer
2k views

Why wp_mail() function isn't sending any emails and displaying '0' in Chrome 'Network' response

I'm trying to send emails through WordPress using the wp_mail() function and it doesn't seem to work. It's displaying 0 in Chrome 'Network' response with Status Code:200 OK This is my code part: ...
0
votes
1answer
35 views

URL rewrite rule

I have taxonomy product_brand and product_cat I have a link: /product_brand/brand_name/?attributes[product_cat]=product_cat_id How to convert to pretty url? /product_brand/brand_name/...
0
votes
2answers
4k views

Use an anchor link to open an iframe inside a Wordpress page

My Question: How do you make an anchor link to an offsite webpage that when clicked opens up the offsite webpage as an iframe that is inside a new Wordpress page where the Wordpress header and footer ...
-1
votes
1answer
355 views

How to hide Ads From Certain Categories?

I'd like to hide our some ads codeblocks from appearing on certain categories/-also category posts- in Wordpress. How to do that? I would like to post some content to certain category and I want to ...
0
votes
1answer
4k views

Create new folder and upload files to custom folder via wp_handle_upload

I am using wp_handle_upload to upload files from a theme template file. if ( ! function_exists('wp_handle_upload') ) require_once( ABSPATH . 'wp-admin/includes/file.php' ); $uploadedfile = $_FILES['...
3
votes
2answers
124 views

Display a text message if the shortcode is not found?

I'm using the do_shortcode function to add a shortcode in a page. But I would like to check if that shortcode exists before displaying it. If the user has no gallery, I would like to display a message ...
1
vote
1answer
386 views

How to Reference/Echo Variable from Another PHP Function

I have successfully set up a PHP function for my blog posts to create a shortcode to automatically display/style an iFrame tag for a YouTube video, as well as pull in the duration and view count ...
0
votes
1answer
3k views

Upload file could not be moved to wp-content/uploads

I know it has been asked over and over again on the internet and i spend hours digging deeper into the web. But the no answer so far. Why we get this error when you upload a file The uploaded file ...
0
votes
0answers
25 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 ...
2
votes
1answer
2k views

Woocommerce auto cancel On-Hold after X days

I have searched high and low but with no resolve. So we developed a custom "bacs" type gateway for our site. Here in Brazil you can pay via a bank billet. The billet usually has an expiration date for ...
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 ...
3
votes
2answers
4k views

Wordpress Infinite Scroll without using any plugin

Background information can be skipped. I wanted to use the infinite scrolling option on my Wordpress theme, but I am not well trained in Javascript so I tried this solution: https://wptheming.com/...
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) &&...
0
votes
1answer
381 views

function sanitize_title() does not appear to be working

Spent quite a while trying to figure this out. I've implemented a stop-gap function that mimics what I believe this function is supposed to be doing, but I would like to use the native libs/functions ...
2
votes
1answer
17 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 ...