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

Change the “Show All” button in a Wordpress Portfolio Filter

I'm working on a website for a client; https://www.lingvox.services/ and I'm trying to solve an issue on this page https://www.lingvox.services/mobila-la-comanda/ The client is Romanian, and wants the ...
0
votes
0answers
6 views

WP CLI Run WP_CLI\Utils\format_items before script finished

How can I run WP_CLI\Utils\format_items before the command has finished? Currently the output will only get returned once the command has finished, kinda like WP_CLI::success('This message will first ...
1
vote
0answers
5 views

Making BuddyPress Activity Stream (Post Type) Featured Images Clickable

I've added woocommerce product postings as a post type to BuddyPress Activity stream via this code in bp-custom.php file: <?php add_post_type_support( 'product', 'buddypress-activity' ); ...
0
votes
0answers
13 views

Calling PHP function with AJAX

I am creating a plugin for wordpress for the backend. I when the admin press a button a js function is being called. In this js function, I am calling an API, and then I want to call a PHP with the ...
2
votes
0answers
27 views

Change title and meta description in included page (not template)

I'm trying to change title and meta description for pages used for products. The goal is to have the same effect as here: <script>document.title = "<?php echo $new_title; ?>";<...
0
votes
1answer
15 views

register_setting & add_settings_error validation issues with multiple fields

I've been trying to use the Settings API for the first time. I managed to piece together a working example but I'm stuck on how to make multiple input fields required. Right now I have an admin ...
1
vote
0answers
7 views

Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?

TLDR - After manually updating a custom post, my WP_Query will change it's sorting order and move that updated post to the end of the array response. I have a custom post type called Events that use ...
0
votes
0answers
21 views

Creating multiple tables with Plugin

I opened a new question, just to be sure. The former request has partly been resolved. I got another question regarding creating tables for wordpress: Only one table is created (The first one), but ...
0
votes
1answer
17 views

Cant get blog name with get_option

I am using WordPress functions to get the blog name and the current user username, I need this info to embed them on my contact form which is custom code too, but for some reason they are not working ...
0
votes
0answers
16 views

Sending current featured image to email

I am trying to send the featured image with other details by email to admin. Everything is working well except that the featured image is sent to email only when the post is edited from admin. If ...
0
votes
0answers
5 views

Display states according to selected country

I am trying to display state's names responsively based on what country is selected from a list (via WP database). For example, user selects Malaysia, Kuala Lumpur will be displayed without the entire ...
0
votes
0answers
20 views

WordPress 5.6 Application Passwords

I have reviewed this page but could not fully understand it. Does this feature in 5.6 provide us with an interface? The page displayed above did not appear in my admin panel. Also I write url ...
0
votes
1answer
23 views

Where to add my PHP codes for AJAX Jquery to work?

I am trying to display state's names responsively based on what country is selected from a list (via a library). I reckon I needed to use WP AJAX and Jquery to achieve this goal. I am totally new to ...
1
vote
1answer
36 views

How to check if a meta value has already been assigned to any user?

On my website I automatically generate an 8-digits random number $rndnr via wp_rand() during the registration process and save it as user meta. How can I check if this number has already been assigned ...
0
votes
0answers
4 views

Hide out of stock only from shop page, not single product variations

So I currently have a shop that uses different variations of products as the sizes. I have added some code that "greys out" any variations that are out of stock in the drop down on my single ...
0
votes
1answer
10 views

I want to insert a link inside a tag page that will link to another page tag

Could someone help me? I want to insert a link inside a tag page that will link to another page tag. This is the code (on the answer paragraph): Link from tags to tag pages displaying all posts with ...
0
votes
0answers
18 views

WordPress MySQL update

Help me correct this code. public function new_product($product = array()) { if ($product['product_name'] == '') return; global $wpdb; $table_name = $wpdb->prefix . '...
0
votes
0answers
9 views

Weird fonts showing which are coming from database

Recently my website was hacked. Then I recovered it and uploaded files to server. But I can see there are lot of weird fonts showing in the site like headers, footers, contents etc. I am not sure what ...
0
votes
1answer
24 views

Display the list of user's comments + the post title + date

I am trying to display the current user's ALL comments in a specific page and I'm using this code (uses a shortcode): https://blog.ashfame.com/2011/01/show-recent-comments-particular-user-wordpress/ ...
0
votes
0answers
6 views

Creating page and post specific ACF Gutenberg blocks

I'm creating custom ACF Gutenberg blocks my a site and have successfully managed to register my own blocks. Now, I have a custom post type called Blog. I do not want blog to show all my ACF Gutenberg ...
0
votes
0answers
8 views

ACF in WooCommerce order-details [closed]

Need to add a field to the WooCommerce order details page where I can add a tracking number in the order page to be displayed for the customer. I have added ACF to the order-details.php template as ...
0
votes
1answer
14 views

Force REST API Authentication for each request method

WordPress end points default rules, GET ----> PUBLIC POST, PUT, DELETE ----> AUTH How can I force authentication the WordPress REST API GET method requests?
0
votes
0answers
11 views

Get all Gravity Form entry IDs for current user and display the highest value

I have a Gravity Form with a user registration plugin installed, so every time someone completes the form, they are added as a user and the submitted form is assigned an entry ID which is linked to ...
0
votes
0answers
8 views

Show php list items in Elementor loop [closed]

I want to show all sub-categories in category page. I have a php code that returns all sub-categories and echo them to the page as html elements. <?php $cur_cat = get_query_var('cat'); $new_cats = ...
1
vote
0answers
11 views

Ajax loaded form replaces form action with Ajax url

I am making a Wordpress website using WPForms to use different forms. These WPForms are loaded in a modal using an Ajax trigger on a button click. When I click a button, the ID of the button is used ...
0
votes
0answers
20 views

Wordpress Standard Fix Errors

I get the following error while fixing my wordpress plugin standards. Use placeholders and $wpdb->prepare(); found $sql Below is my code... public function get_db_value() { //getting ...
0
votes
0answers
10 views

How To Show Featured Products First In WooCommerce

I am working on a Woocommerce theme that outputs first featured products and then products. The following args I am passing to the WP_Query. But it just returns only the Featured Product. If anybody ...
1
vote
0answers
5 views

How to hide products that do not have an image from a slider carousel for an ecommerce webpage?

I am using a plugin for a product carousel on an ecommerce webpage. I would like to hide products that do not have images from the carousel. I am very new to all of this. It is my first webpage ever,...
0
votes
0answers
15 views

Get title of page containing post grid within the posts

I have a page containing a post grid. Within the text of these posts I want to use a shortcode to display the title of the page containing this grid. So, when my page title is "test" I want ...
0
votes
1answer
14 views

Featured or last post with a different WordPress style without plugin

How do I get a highlight with only one category but with a different style for each ? Exemple: My Code is: <?php $args=array( 'cat' => 2, ...
1
vote
1answer
11 views

Ajax category filtering products default show all

I have code that list categories and products by category. When I click "All" it list all products, but when I go /products page it's not list all products by default and I need to click &...
0
votes
1answer
37 views

Headers already sent error with get_template_part in REST API call

Crosspost from StackOverflow I've looked at multiple other questions about this warning (Headers already sent...etc) and this thorough explanation, but I'm not finding a solution for the circumstances ...
0
votes
1answer
18 views

wp_dequeue_script for a Plugin

I am trying to remove a line of script in the footer of my page that a plugin is inserting on pages that I am not using the plugin at, homepage for example. I am using the below code for some reason ...
0
votes
1answer
17 views

PHP code for displaying Wordpress posts in a static page not working

I have a website homepage that is static. There is a separate blog hosted on Wordpress on the same domain (at /blog). Six years ago, I asked a friend for help with displaying two recent posts from the ...
0
votes
1answer
25 views

How to add PHP code in functions.php wordpress

<?php //Insert ads after second paragraph of single post content. add_filter( 'the_content', 'prefix_insert_post_ads' ); function prefix_insert_post_ads( $content ) { $ad_code = '<div&...
0
votes
0answers
6 views

Where can I find information whether my GeneratePress parent theme loads its style using a function starting with get_template OR get_stylesheet?

Where can I find information whether my GeneratePress parent theme loads its style using a function starting with get_template, such as get_template_directory() and get_template_directory_uri() or If ...
0
votes
0answers
20 views

Problem with displaying CSS Stylesheets - Am I adding them correctly in my wordpress child theme?

Is this a proper way to load CSS files into my WordPress child theme? add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); add_action( 'wp_enqueue_scripts', 'case_studies_styles' ); ...
0
votes
0answers
17 views

How to access specific product id on other pages/posts?

I have the following code, which is adding some HTML to the product page, according to the product and its fields, attributes, etc. add_action('woocommerce_product_meta_start', 'addHtmlToProductPage');...
0
votes
1answer
28 views

How to add Text before my Custom Term and hide it when empty

This is my code: <?php $terms = get_the_terms( $post->ID , 'this_is_custom' ); $links = []; foreach ( $terms as $term ) { $term_link = get_term_link( $term, '...
0
votes
0answers
11 views

Add SEO meta data with PHP to pages generated by plugin? Pages are not generated as posts in WP

I am using a real estate IDX plugin (Showacse IDX) that generates pages that are not posts in my wordpress database. The poorly developed plugin does not give some of these pages meta descriptions. ...
0
votes
2answers
18 views

How to modify html of my wordpress homepage? [closed]

I am working on my website and I'd like to modify small details of the homepage. I found the exact line i'd like to modify in the code inspector in firefox, but I don't know to which actual files this ...
1
vote
0answers
33 views

Question about repurposing WordPress 404 handler

I've been experimenting with repurposing WordPress's 404 handler/template file for a Real Estate site that I'm developing. I understand that when a non-existent URL is requested, the 404 page gets ...
0
votes
0answers
13 views

Move Featured Image to Right of title [closed]

I am looking to move the featured image to the right of the title but above the sidebar. I want it to look something like this: https://imgur.com/a/jw9eU0r. Essentially I would like to have the blog ...
1
vote
1answer
21 views

How to exclude category ID from Looper in Wordpress

I'm trying to exclude 2 (and potentially more) ID's from my loop, that displays all categories that have posts. The category ID's i'm currently trying to exclude are 1 and 19. I'm very new to PHP but ...
0
votes
0answers
8 views

'Make this my store/change store location' feature for custom post type store-location

I'm very new to the Wordpress environment so please go easy on me with the following question. I have a custom post type store-locations. I am trying to offer the user the option to make a store ...
0
votes
1answer
20 views

WordPress hit memory limit but not from the server

I have struggled with this for hours and days. I need good ideas for a fix now. When I do a certain action in WordPress, I sometimes get a Fatal memory error. The error comes after I hit "Update&...
0
votes
0answers
25 views

One account with multiple logins

I have searched google and this site and can't seem to find an answer. I would like to be able to add multiple logins for an account. Meaning one account could have several emails and passwords ...
2
votes
1answer
47 views

Is $hook a global variable in WordPress

// only run on dashboard page if ( 'index.php' != $hook ) { return; } There is a plugin on the Wordpress.org repository that checks PHP current version. I happened to read its code and came ...
0
votes
0answers
15 views

Wordpress all php BUT index.php downloads instead of loads

I've looked around a couple other solutions, but none have worked so far (modifying .htaccess, emptying .htaccess, disabling themes,plugins). My website works fine, the index.php in the root directory ...
0
votes
0answers
7 views

get orders of today's date

I'm trying to get all the orders of the current date as the product page loads for example orders of today's date 2021-01-13 I have checked this but this didn't help me. Here is my code $args = array( ...

1
2 3 4 5
188