Stack Exchange Network

Stack Exchange network consists of 174 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.

1
vote
0answers
12 views

Wordpress can't find temporary folder, but folder it's looking at has correct permissions

So, I've spent a couple of hours looking around the internet to try to figure out this problem, since it seems like a dumb one that would probably be a duplicate, but apparently it isn't. I'm hosting ...
1
vote
2answers
55 views

Display FNumber (aperture) as a number versus a fraction

I'm a newbie at even trying to work with PHP, but thinking there may be a simple solution to this. EXIF exposure data is only displaying an "s", so there must be an error. I'd also like to display ...
1
vote
1answer
98 views

Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?

I have been follow a tutorial here: https://rudrastyh.com/gutenberg/remove-default-blocks.html Where it discusses how to remove default Gutenberg blocks like so: add_filter( 'allowed_block_types', '...
0
votes
0answers
16 views

Re-Use WordPress Admin Tag/Category Selector

I want to re-use the frontend tag/category selector that is used when editing a post in the WordPress Admin. I have my own data API that I want this to connect to, rather than searching for tags/...
0
votes
1answer
30 views

Correct way to make static pages editable in wordpress

I am in the process of converting a small static website with 5 pages into a WordPress site. I have created a custom theme and created the pages (Home, About Us etc) from the Wp backend. I have ...
0
votes
0answers
19 views

Redeclare / override WooCommerce core function

So, I am adding my own drop downs on the shipping section in the checkout of woocommerce. They will filter the options via jquery to only show and hide the valid options of the user (they have to pick ...
0
votes
2answers
31 views

CSS change in woo commerce Place Order Text [closed]

add_filter( 'woocommerce_order_button_text', 'woo_custom_order_button_text' ); function woo_custom_order_button_text() { return __( 'Your new button text here', 'woocommerce' ); } Above is the ...
0
votes
0answers
7 views

Get Woocommerce $email->id inside file a file email-order-items.php

I'm customizing some woocommrce files, which need to get woocommrce $email->id, i checked on main email templates like customer-completed-order.php which have $email object but in email-order-items....
0
votes
0answers
15 views

How do I implement a check for correct answer of question on specific page?

I have multiple Woocommerce product pages which would only allow users who had answered a question correctly to view. Each product page would have their own question and should be treated separately. ...
0
votes
1answer
13 views

Redirecting the lost password page request when using a custon login page

I have a custom login page and hence have setup the following redirects: add_action('init', 'my_redirect_login_page'); add_action('wp_login_failed', 'my_custom_login_failed'); add_filter('...
0
votes
1answer
17 views

When to use wp_register_script() function?

When I came to know the function wp_register_script(), I had some questions came to my mind: Should I register each script first and then enqueue it? And is this a best practice? Or, Should I ...
0
votes
0answers
16 views

Need help to create Wordpress page that decodes a text file and publishes it in JSON format

I would like to create a Wordpress page that lists temperature and humidity data. The data originates in an encoded .txt file. I'm using the following PHP file to decode the data in the text file. I ...
-1
votes
1answer
18 views

explanation for activate_plugin function in wordpress core

This function is in plugin.php file in wordpress core. I read the code and didn't get quietly what does it do. Can anyone give some explanation for this function?
0
votes
1answer
20 views

setcookie() issues on running with HTTPS on WordPress

I have set 2 custom cookies to be saved when user clicks a button that runs the script to save the cookies. The issue is that I need these to be saved through HTTPS because I am using them on a store ...
0
votes
1answer
23 views

How to include a custom field in the woocommerce email?

I have added a custom field on the checkout page using this: add_action( 'woocommerce_checkout_fields', 'woo_add_conditional_checkout_fields' ); function woo_add_conditional_checkout_fields( $fields ...
0
votes
0answers
16 views

Adding PHP to an if else loop

I want to run some PHP to show custom fields in a page; <?php $showExcerpt = get_theme_mod( 'auto_excerpt' , '' ); if( is_single() ) { the_content(); } else { if ( $post->...
0
votes
1answer
20 views

Change order of custom submenu link in WP Admin?

I've added a custom link to WP Admin under the Users menu, but trouble is I can't seem to get it to display above the default options. Is this possible? My code: // Add sub-menu option to users menu ...
0
votes
0answers
26 views

Make bootstrap carousel dynamic in Elementor Widget

I want to have a quick solution. I am not good at backbone.js so I am getting little trouble here. Here is my code: https://pastebin.com/KB4vhkkY I have made a widget for Elementor for a bootstrap ...
0
votes
0answers
12 views

How to make a vote in the poll for registered users?

I have a poll, the vote of which must be closed for guests. <ol class="zf-structure-list zf-quiz_answer zf-text zf-clearfix"> <?php if( isset( $question["answers"] ) ) { ...
0
votes
0answers
10 views

WooCommerce Product Import from Unfamilair Feed Type

I am trying to import products into WooCommerce and usually get this done using a WooCommerce product Migration Tool (Like 'WP All Import') which requires the file/url to import be in either XML or ...
0
votes
0answers
16 views

My blog posts section seems to be rendering the other blog posts inside the first? :/

After a recent Wordpress update, my blog page seems to be rendering the 1st post with all the other posts rendered within the same div. It was working before but since the update, this and the ...
0
votes
0answers
15 views

Add number in increment of one to menu items

I'm trying to add sequential numbers to menu items in increments of one. So right now where I have the following: <li class="menu-item menu-item-type-taxonomy menu-item-object-category"></...
0
votes
1answer
22 views

Bring Font Awesome icons inside menu A tags

I'm using the underscores _s bare bones theme and have made a second menu for which I've added font-awesome classes to the optional CSS-classes for the menu's navigation labels to produce icons ...
0
votes
0answers
15 views

Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)

<div class="container"> <?php if( have_rows('director_information') ): ?> <div id="accordion" role="tablist"> <div class="row"> <...
0
votes
1answer
20 views

Difference between “Walker_Nav_menu” and “walker”

Does anyone know what is the difference between extending Walker_Nav_menu and walker. I learned about Wordpress Nav Walker and found several different tutorials. Do they extends different classes ?
0
votes
1answer
41 views

How to get total gross revenue for current month in the woocommerce dashboard status widget

I need to show gross sales for the current month in woocommerce status widget in admin dashboard. Currently it shows net sales amount I need to change to gross sales amount.
0
votes
2answers
43 views

Use WP Cron to Clear a Page Cache?

I'm using a plugin (Comet Cache) to save static versions of a particular page I have on my site. Inside the plugin, I have the cache set to clear every 2 hours (that way this page can show the ...
0
votes
0answers
17 views

Wordpress - GraphQL Intergration

Here is what I'm trying to do. I have a GraphQL plugin and it is only pointing to the localhost. However, I would like to have WordPress point to the external server. I would like to do the ...
0
votes
0answers
62 views

PHP Error Backtrace / create_function deprecated

After installing PHP 7.2.10, the following error appeared: PHP Error Backtrace Backtrace from warning 'Function create_function() is deprecated' at /var/www/site/data/www/site.org/wp-config.php ...
0
votes
0answers
16 views

Using $this with an anonymous function in filters

Okay so I have a method within a class which looks like $this->addToSitemap('page', $urls); This is used to append extra pages to the Yoast Sitemap. Here 'page' is the type of sitemap within ...
0
votes
0answers
10 views

User switching through frontend without going to wordpress admin panel

I have two user roles for example, 1.staff 2.Instructor I need to switch to staff when I am in instructor when clicking a button in frontend. As same as I need switch back option also to switch back ...
0
votes
0answers
20 views

how do I link a php or xml data file to current html page inside WordPress

I have three files sitting in the same directory on my Mac. They are; LiveSearchHtml.php, LiveSearch.php and links.xml They linked to each other to deliver a "live search" function based on data ...
0
votes
1answer
10 views

Pulling Individual Posts from WP_Query

I'm trying to run a WP_Query and then put each of the 3 posts pulled from that query into a differently formatted div in my template. However, when the code below runs, I end up getting the first post ...
0
votes
1answer
29 views

Ajax $wpdb not returning table data

I'm using WordPress 5.0.2 with WooCommerce 3.5.3 and I have two selects dropdown field on the checkoutpage. I want to retrieve the selected region_code value from the billing_region dropdown and then ...
0
votes
2answers
33 views

Create an unique ID number after submit form

I'm still learning PHP and MySQL and need to create a unique number in Wordpress site (as a order number ID) every time, when user fill and submit "order" form from frontend and save it to database. ...
0
votes
0answers
7 views

Woo commerce import excel file and add contents to shopping cart

I am looking for some code that will allow my site users to upload an excel file and the code will cycle through each row and add the product shut in cell a and the corresponding qty in column b to ...
0
votes
0answers
19 views

Dynamically set front page featured image from first image in latest post's ACF gallery

My front page template is set to display the full content of the latest post using WP_Query and a custom page template. Now I want the home page featured image to dynamically change every time a new ...
0
votes
0answers
23 views

Get meta values from parent post and save in child post

I have a custom post type "E-Books" with two categories "E-Book Title" and "Chapter Page", and custom meta boxes (table of contents, etc). The E-Book post type uses one page template, and displays ...
0
votes
0answers
22 views

Apache ERR_CONNECTION_REFUSED on Ubuntu with php enabled

Context: I'm trying to copy my Wordpress - WP site locally on Ubuntu. I'm using Vagrant with a Virtualbox - VB. A Lamp stack is installed in the VB with Apache/2.4.29, Ubuntu 18.04.1 LTS and PHP 7.2. ...
0
votes
1answer
24 views

Filtering markers on google map by WordPress category[SOLVED]

I have created the Google map with posts as markers but no I want to filter those markers by category and I’m stuck. Here is my code: functions.php $args = array('post_type' => 'post',array( ...
0
votes
0answers
22 views

More pages avaible than max number in pagiantion

I found out that my pagination display for example max 2 pages but I can freely go to (max) 5, changing the number in the url address. It' avaible until I change the value to 6 or more, then I got 404....
2
votes
0answers
47 views

How to return output of the new wp gallery block for automatically Link images To Media file

Sorry for the repeated questions but I didn't get any solution yet! I'm stuck with that!! I mange a multi writers blog, and all our users uploading some gallery images, and they didn't know the ...
1
vote
1answer
28 views

Handling Body class based on Template

Through a PHP function, I think I can handle body class, but I think WordPress would have some specific way to handle it. If Home.php then class in the body should be wbody else it should be bgody. ...
0
votes
1answer
14 views

WordPress Recent Posts - Loop

I would greatly appreciate some help, I have written a loop inside a list item however I'm looking to set a width and height on the thumbnail and display some expert "text" but limit the length of it.....
0
votes
0answers
17 views

help about site content

I'm using web platform installer 5.0 to run a WP site on my server 2008, and I need other pc can see it. I have changed site url to my IP, WordPress url is http://localhost/wordpress. They were able ...
0
votes
1answer
64 views

Trigger popup in a php if/else statement

I am trying to trigger a popup within functions.php if certain conditions are met. The if else statement it self works perfectly, but I can't get the popup to open. I've tried calling a shortcode but ...
0
votes
0answers
14 views

Warning: Cannot modify header information - headers already sent when trying to download a simple text file [duplicate]

I want to be able to click my "Export" button and have a text file downloaded. When I try this, I get the error: "Warning: Cannot modify header information - headers already sent ....". I have a ...
1
vote
0answers
33 views

different id for same element visual composer [closed]

I have two same elements in visual composer page, I wanna add different custom id to this elements. <div class="posts"> // code </div> <div class="posts"> // code </div&...
0
votes
0answers
19 views

Same content on Wordpress - Pagination with custom query

I am making own template for WP and I have problem with pagination. The content is always the same on every page. I read many pages about this problem and I implement the solution, but it doesn't ...
0
votes
0answers
17 views

How to block certain keywords from searching and redirect to different page on Wordpress?

I would like to block certain keywords (multiple keywords, banned keywords like fuk, sit etc.) from searching on Wordpress blog and show/redirect visitor/member (searcher) to different page. Used ...