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

Create shortcode for metabox gallery

I have a metabox gallery in a custom post type. Usually I display the gallery in the front end using the following PHP code in my theme: $gallery_images_1 = get_post_meta( $post->ID, '_post-metabox-...
0
votes
1answer
21 views

Woocommerce disable order item link (backend) [closed]

I'm facing a problem where I couldn't disable the order item link for the backend (user role: shop manager). I've found some solutions but only tackle to the front end (customer-order page). However, ...
0
votes
2answers
27 views

Allow a user or role to view drafts and previews, but not other admin privileges?

How do I allow a specific user or a specific role to view drafts and previews, but not allow them to edit posts or have any other admin capabilities? I can add a custom capability to a role, but don't ...
0
votes
0answers
18 views

Retrieve alt text by referencing the img src

I have a website with 400+ images. Using a spreadsheet plugin I've been through and manually added alt text to each of the images. The problem I have is that the pages are built with a page builder ...
0
votes
0answers
28 views

Alike Shortcode using in Custom Shortcode

I'm using Alike plugin to compare my custom post types, Alike provides shortcode [alike_link] to run the procedure and I have created a shortcode to display my custom post type. In this shortcode I ...
0
votes
0answers
21 views

Get all post under custom post type grouped by custom filed value in custom taxonomy

I have a custom taxonomy (product_category) which has some subcategories and custom posts (product) with a field series, which is a checkbox with values s1,s2,s3, etc When I choose the last ...
0
votes
1answer
36 views

How to add the sidebar to all the pages except the home page? [closed]

I am creating a theme and I need some idea to create a below structure on my all the page except on the home page. I know how to create a menu, sidebar, footer, and call dynamically on the page. My ...
1
vote
0answers
33 views

export a csv file from the database with a cronjob

I'm using an event plugin, which doesn't have a user-friendly function for showing a list of bookings. That's why I wrote a php+js script myself to display that data in a nice way. But to use my own ...
0
votes
0answers
26 views

Prevent header and footer from loading on specific pages with template or plugin

I am working on a client's site that has a few pages that are embedded into a mobile app through WebView. The goal is to prevent the header and footer from showing up on these certain pages. I can't ...
0
votes
1answer
41 views

How to test nonce with AJAX - Plugin development

I built a plugin, but now on end, I am not sure whether my nonce integrated correctly, and I'm not sure how to test them. Can anyone help me test it or let me know if the nonce is integrated correctly?...
0
votes
1answer
28 views

Create an array with all the links of the years' archive (of a custom post type)

I have a custom post type called "papers" and I need to create an array with all the archive links per year that exists. Something like: array ( [0]=> 'http://www.example.com/2021/?...
0
votes
0answers
13 views

Grouping custom wordpress post types by acf value

I'm trying to group custom post type shop by same the_field('shop_type') select values clothes, food, etc. Result would be like: Clothes Custom post type title 1, Custom post type title 2 Food Custom ...
1
vote
0answers
17 views

How to save checkbox values for logged in users?

Hello~ How can I have checkboxes save their values for a logged in user? My Wordpress website features various checklists in a table format. When a user finishes a task on the list, they would be able ...
0
votes
1answer
28 views

Header not properly displaying on archive.php

I am making a basic wordpress theme for the first time and I've finally gotten everything to mostly play nicely. The header displays perfectly fine on every page except the archive page (where blog ...
0
votes
0answers
50 views

Get taxonomy terms that share a common object property

I have a custom taxonomy called 'issues' that has some properties (term_id, name, issue_year, etc). I want to get all the terms by year to display on a page. I need to get all terms of the taxonomy ...
0
votes
1answer
11 views

Attempting to list all product categories and the price range of all products within them

I'm trying to display a list of all product categories and the price range of the products within those categories. E.g Headwear – £30-£150 Shoes – £35-£300 Where "Headwear" is the Product ...
1
vote
1answer
33 views

WP_Query Check if post has one or more attached medias

Is there any way to check if post has any attached medias via new WP_Query($args)? $args = [ 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 10, 'paged' =&...
0
votes
1answer
43 views

Display just one post from a loop of 5 posts?

Let's say I have this Query to which I fetch all my WP posts and then use PHP to filter out even further: <?php $posts = get_posts(array( 'tax_query' => array( array( ...
0
votes
1answer
11 views

Order users by random not working?

So I'm trying to list my wordpress user id's each time in a random order. Right now I have this, but for some reason, 'orderby' => 'rand' is not randomizing the list. <?php $args = array( ...
0
votes
0answers
21 views

My Custom Post Type AJAX Query is Returning no posts - why?

When I run this query on posts_type => "posts" it works just fine. But when I add my custom post type 'post_type' => 'case-studies', I get no results. The custom post type has a custom ...
0
votes
0answers
11 views

how do i add custom widget woocommerce shop page with php

I want to create a widget that will only appear on the shop page, but I couldn't get any results. functions.php function kucuksun_widgets_init() { register_sidebar( array( '...
1
vote
0answers
39 views

How to store data from multiple forms using ajax and php

I have custom post loop, and for each product I have form. I'd like to store data in array for each click submit button in each product. E.x. Product A with Form and some values (price,quantity) click ...
0
votes
1answer
89 views

Display all comments post not work in Edit comment page

I am trying to show all comments related to the post the comment being edited belongs to. My code (based on this example) add_action( 'admin_menu', 'all_display_comments_add_meta_box' ); function ...
0
votes
2answers
219 views

Wordpress admin-ajax.php 400 bad request

I try tu run wp form with ajax but console return Wordpress admin-ajax.php 400 bad request. jQuery(function ($) { $(document).ready(function () { jQuery('#...
0
votes
1answer
19 views

Styling a category link

I am still learning but I wasnt able to style a category link. I was able to create the following so only 1 category link is displayed. But I was unsure how I can modify this so I can add a class and ...
0
votes
0answers
17 views

How to get brand children with woocommerce brands

I am running into issues attempting to get the child brand terms for our product page. Product brands are setup like this below. BRAND MODEL MODEL MODEL BRAND MODEL MODEL ETC.. I am trying ...
0
votes
0answers
25 views

WordPress Custom Form - Getting Query Vars, Weird Glitch?

I want to start by saying thank you to the SE community for helping out over the years. I am trying to create a feature for our website that takes a customer zip code and updates the product inventory ...
1
vote
0answers
23 views

I cant receive an HTTP POST request correctly

I have some code that is supposed to process a POST request that is sent to the page. Whenever I try to send the post request to the file outside of WordPress it works flawlessly. However, whenever I ...
0
votes
1answer
34 views

Push Contact form 7 variable to front end after submission

I have a contact form 7 form that's sending information to an API. I want to display the API response on the front end. I record the user information, then post it using wp_remote_post, with my ...
0
votes
0answers
57 views

Post form - AJAX won't upload featured image - Plugin development

I have a form for adding a post via AJAX and PHP. I have three fields. Text, textarea and file input field. Everything it's working, but it won't upload a featured image. When I remove the AJAX call, ...
0
votes
0answers
13 views

Creating plugin with front-end pages

I am trying to create a logged in-section for a wordpress site. I am trying to do this in the form of a plugin to be able to reuse it easily for another site. The idea is to create a new user role (&...
1
vote
1answer
63 views

Can I write 'RewriteCond' using 'functions.php'?

I want to add 'rewrite condition' in .htcaccess but unfortunately I don't have access of that. Can I write conditions in functions.php ? If yes, how to achieve that ? I want to add these lines: ...
0
votes
0answers
17 views

Woocommerce display orders with products from specific categories to specific admins

I am new at stackoverflow. I have a question about wordpress. I am building a wordpress site for some cinemas with movies. Each cinema is a product category. I want enable an admin cinema1 which will ...
0
votes
0answers
31 views

Error establishing a database connection (Set-up locally)

This is my first time working on Wordpress and accessing site locally. The Wordpress site is on the github and I tried to pull the codes from there and accessing site already to my local machine but ...
0
votes
1answer
18 views

Storing huge number of users in wordpress

I would begin coding a school management theme project soon and am looking to keep the DB neatly organised. In this pursuit, since the students could be thousands in a school, would it be a good ...
1
vote
1answer
26 views

Using several custom fields as custom post title

I have stumbled upon a brilliant piece of code that just fits my needs on this thread : Using custom field as custom post title by @chrisguitarguy and I was hoping there might be a way to tweak it to ...
0
votes
0answers
70 views

$_POST returning empty values

I have created a form, as shown below that displays according to a switch statement. I am needing the inputs from the form submission to either be saved to a table in the WordPress Database or to be ...
0
votes
1answer
19 views

Redux option doensn't seem when include from functions.php

When I write redux framework option into header.php, it is shown.However when I add the same php code into a php file and include the php file from functions.php, it doesn't seem. header.php: <?php ...
0
votes
0answers
20 views

Is there a way to get a wordpress user's metadata using an external script

I want to make a script that when it receives a post request with the username and password then it checks if the username and password are correct then it finds the number of coins the user has (i ...
0
votes
1answer
23 views

Custom meta box values are not getting saved for my custom post type

I have created one dummy post type to check the values, if it's getting saved or not. However it's saving values for 'text input and text area' but remaining values (checkbox, select, images) are not ...
0
votes
1answer
40 views

unable to use 'new WP_Query' in AJAX call

I'm trying to create category filter for posts. I usually work with get_posts function but this time I need to keep pagination, that's why I'm trying to use new WP_Query. I have successfully created ...
0
votes
0answers
9 views

How to exclude meta no index pages from wp_list_pages

Can I exclude pages that use a meta no index or are no indexed from a plugin like Rank Math from wp_list_pages args?
0
votes
0answers
9 views

Set all WooCommerce Products to Simple, Virtual & Downloadable

I want so set my all products of my WooCommerce store to Simple -> Virtual and Downloadable Programmitacly. And hide all the Unwanted tabs & fields like shipping, Inventory, etc.
0
votes
1answer
27 views

Remove Author Links

I'm trying to remove the author pages as well as the links to the author pages on my wordpress website powered by Divi. First, I disabled author archives and pages with the Yoast plugin. Then, I used ...
0
votes
0answers
26 views

Wordpress redirect to a subpage - how to create a template for subpage?

So I have the author.php which is the author page showing all information and posts for the author. I'm trying to create a subpage template (example.php) for the auhthor.php so that I can showcase ...
0
votes
0answers
11 views

Removing links from Grouped products

Looking for a way to remove links to single products when they have been grouped. Ie dont want users to link back to the single description as all products are displayed on one page. Have tried ...
0
votes
0answers
27 views

Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)

I need a live search with wp rest api with autocomplete, in vanilla js. I found this plugin makes exacly what I needed. (I dont need this code as a plugin, its not a problem, but if it helps to make ...
0
votes
1answer
73 views

Where exactly do I write define( 'WP_DEBUG', true ) in wp-config file

would anybody know where I would write WP_DEBUG in wp_config file. I don't see it there. I would like to check why my javascript is not working. I have enqueued everything with php in the functions....
0
votes
0answers
40 views

Query custom post type that has a serialized relational advanced custom field value

I have a custom post type "issues". I am using Advanced Custom Fields to add a relational field called "articles_from_this_issue" where the admin can select multiple articles. I ...
1
vote
2answers
65 views

'orderby' => 'rand' alternative for better performance?

I have been told that using this in the array: 'orderby' => 'rand' will cause this: Ordering by random is extremely expensive to query, involving creating temporary database tables, and scans, ...