We’re rewarding the question askers & reputations are being recalculated! Read more.

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

WP_Query order by not working properly due to category I believe

I made a query where it should be ordered by the field external link then by price field the problem it seems that some of the post have multiple category can't seem to figure out why it is not going ...
0
votes
1answer
7 views

Extra editor on top of default in Custom Post Type

Normally there is one editor by default in any custom post type. I want one extra + If extra is possible how will we print it in the front end. For a default we do it like this: the_content(); what ...
0
votes
0answers
17 views

Cron job -many duplicate posts

i have news aggregator website and have many sources need sometime to update in one minute maybe 7 new posts i make more cron jobs in cpanel every minute,every two minutes,5minutes but problem is ...
0
votes
0answers
16 views

retrieve thumbnail id from best selling product in category

The below is just an overview of functions etc ive used to get the resulting variable $image. The code gets the manually set thumbnail and $image is used to display the thumbnail along with taxonomy ...
0
votes
2answers
21 views

Adding if statement

I'm pretty new to PHP however have managed to put together a site I'm happy with. Once small issue I am having is that I would like to add content for users with specific roles, this means adding an ...
0
votes
0answers
24 views

Separate categories from my submenu and their latest posts

I have a menu with <? php wp_nav_menu() ?> in which I integrated a Walker menu to be able to display the latest posts for each category of my submenu! It works, but I would like to have the ...
0
votes
0answers
16 views

How do I remove the pagination terms after a single URL?

Here is a single URL 10stuffs(dot)com/technews. and it also displays the result when we add pagination terms like 10stuffs(dot)com/technews/page/2. I just want to keep the URL like this 10stuffs(dot)...
0
votes
1answer
16 views

Only show size attributes in product box woocommerce when available

First of all I want to say I have little coding experience. I want to show available sizes in the productbox on the shop page. I got this working after some searching around here. Now I want to only ...
1
vote
0answers
26 views

Show comments menu in dashboard only if the site has comment

I would like to hide "Comments" menu in Dashboard until the site doesn't have any comments. I tried to do this with this below code, but doesn't works: function remove_mainmenu_pages() { ...
0
votes
1answer
24 views

Custom Field used to allow a Free Story; no longer works

Have a news site and until recently, there were two ways to get behind the paywall legitimately. First was with a user/pass that was checked against a remote database and returned an AUTH value of yes ...
1
vote
1answer
80 views

combine Code 1 with Code 2

Code 1 - uses wp_list_categories to list product categories in columns of x categories up to a total of y, with a link to view all categories if there are more than y. Code 2 - Later realising i ...
0
votes
0answers
8 views

Add Button quicktags Wordpress

I am also trying to add this button to "Quicktags" in wordpress. The button appears in "Visual" but not in the "text" toolbar can help anyone with this problem? Thanks :) function wdm_add_mce_button (...
0
votes
1answer
21 views

Array to string conversion on array_map

I'm using array_map to sort out an array with all of my _octopud_id's. var_dump($offices): Returns the following: array (size=500) 0 => array (size=1) 'id' => string '1382' (...
0
votes
0answers
10 views

Woocommerce: How to exclude some products with specific tag ID from Woocommerce REST API

I'm Working on a mobile app using the WooCommerce API and I need to exclude some products with a specific tag id from the /products endpoint. There no options on the docs on how to do this! just ...
0
votes
0answers
20 views

How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?

I'm not a novice web developer. I know how to use Python and Django at a beginner to intermediate level. I know my basic HTML5, CSS, and JS. I've been learning React.js through Scrimba.com as well as ...
0
votes
1answer
14 views

Store metakey value as an array

How could one grab the post meta key of _octopus_id and store that as an array. Here is what I'm trying to achieve: Call the WP_Query and pull all the offices with _octopus_id Use the value of ...
0
votes
0answers
14 views

file_get_contents(.ics file): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request [on hold]

I'm trying to parse an iCal file from Google Calendars URL but it only works when I put the link as parameter. If I try to put a variable containing that URL as parameter it gives me the error: ...
0
votes
1answer
22 views

WooCommerce – template_redirect if is_checkout AND order has been paid?

In my WooCommerce store I would like to redirect to a custom 'thank you page' after payment has been completed. I'm using this code: add_action( 'template_redirect', 'myfunction' ); function ...
0
votes
0answers
21 views

Woocommerce not creating downloadable product permissions in customer orders

Currently having a problem with Woocommerce not creating download links for the virtual downloadable products when an order is placed. This then leads to no link being placed in the email sent to the ...
0
votes
0answers
14 views

What is Wordpress methodology for using Composer-installed packages?

I just set up a composer.json for my site and added a MailChimp package by executing from my root directory composer require thinkshout/mailchimp-api-php The composer.json at root level is now: { ...
0
votes
1answer
28 views

Create short URL with auto 301 redirect

I found this post (Create additional short URL with custom field and 301 redirect) and tried to do this with a custom post type I created but it aint working and I dont know what I am doing wrong in ...
0
votes
2answers
22 views

How to store ACF custom fields data in a custom table

I am using the ACF Custom Fields plugin to store some info, but to my understanding, it is stored in the wp_postmeta table. Is it possible to store it in a custom table instead? So for example, the ...
0
votes
1answer
17 views

Increment paged on WP_Query

What's the proper way to increment 'paged' under a WP_Query call? This is what I have below: $custom_query = new WP_Query([ 'post_type' => 'employee', 'post_status' => 'any',...
0
votes
0answers
21 views

Custom Query - exclude child category post from parent category post loop

I'm trying to change the way wordpress displays posts under category pages. Ex: Cat1 (contain 1 post) Cat2 (contain 1 post) Subcat2 (child of cat2 contain 1 post) Cat3 (contain 1 post) In the ...
0
votes
1answer
60 views

get taxonomy thumbnail and use it as a variable in code

Im having trouble trying to retrieve category thumbnails and use as a variable in some code i got from a JSFiddle. It puts a placeholder image as default and displays a category image on hover of ...
0
votes
1answer
10 views

Target post_date_gmt if it's empty or not set

So I'm trying to target some posts to include in my function but I just can't seem to get it to work. When I have the meta_query taken out I get 9 results (Works): $args = array( 'post_type' ...
0
votes
1answer
13 views

ACF - Get ID of relationship field in flexible content

I'm trying to get ID from a relationship field within a flexible content and push it in a array if (have_rows('studio_blocs')) { while(have_rows('studio_blocs')) { the_row(); $...
0
votes
1answer
20 views

Data fetch and delete by ajax request

I have created a crud reservation form using ajax. The purpose of this form is when the user submits this from the user data will be stored in the database without page refresh. The full functionality ...
0
votes
1answer
14 views

How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?

We are developing a B2B shop with WooCommerce. I want to show the SKU and the product dimensions underneath the product title in the cart. This is what I have right now: add_filter( '...
0
votes
0answers
15 views

How to send new visitor to a splash page for only one time in wordpress?

I have a PHP script that will be the main web platform and would like our NEW visitors that visit our domain to be sent to an (introduction type) Wordpress splash page, and we want this to happen only ...
1
vote
2answers
70 views

OOP Plugin Development. Including external object

I am developing a plugin by using classes and object oriented programming. Within my plugin I have included another object as I need to use the functionality of this other object. I am instantiating ...
0
votes
1answer
16 views

Can I set up a hover animation in CSS depending on a PHP conditional?

I created a 'Light' theme and 'Dark' theme in the WP dashboard (via Advanced Custom Fields) that will determine how a series of buttons will look, depending on which theme is selected: ...
0
votes
1answer
25 views

WP_get_image_editor resizing images in a foreach loop

I am generating avatars from an image file upload. When running the function, WordPress does create the first image image-32x32.gif but fails on the remainder of the loop. I suspect it's due to ...
0
votes
1answer
17 views

$_SESSION variables work perfectly on my local machine but returns NULL on development webserver

I'm using a hook into init where I add a certain timestamp in order to include a splash screen into within my Wordpress project. Basic logics of the script is: add_action("init", "my_function", 1) ...
0
votes
0answers
20 views

PHP Warning: mysqli_error(): Couldn't fetch mysqli in

I am new at this, so this is my case. I am getting this error on my Wordpress site and I need someone to point me out where to search the problem. I know that is written in a log file and here it is, ...
0
votes
0answers
10 views

Update custom plugin using github repo

I've created a plugin that will add some custom shortcode to wordpress. I'm looking for a way to create an auto-updater that will rely on a github repo, this because I want to sell my plugin on a ...
0
votes
0answers
8 views

Simulate “Update” button press

I have recently ran an SQL script to update the values of all products for one of it's post metas (essentially changed the value from 0 to 1). This change doesn't take effect on the frontend until you ...
0
votes
0answers
9 views

Redirect 404 page with ID in slug to associated page with same ID in slug

I got URL's like this: test.com/redirect/p563328-18/ This are pages / urls that doesnt exist (404) but we have custom post types (vacatures) with posts that have the same "id" in the slug: test.com/...
0
votes
0answers
9 views

Accessing array elements WOOCOMMERCE API

I would really appreciate who can guide me with the following: I have the following ARRAY, it is a record of a product in woocommerce-wordpress that RETURNS three DIFFERENT variations: 1837, 1838 and ...
0
votes
2answers
29 views

Remove <H1> page title in product page using a function

I would like to ask how to remove < h1 class="page-title"> in the product page? Here's my sample link: https://pwbackup.panelwallart.com/products/colorful-world-map-on-old-wall-canvas-prints-panel-...
0
votes
0answers
21 views

Check if post meta exists, and use fallback post meta

For some reason, I'm unable to get this to work and I don't know why so here I am. WORKS This just stores an object in the database as _profile_photo_octopus which is what I want. ...
0
votes
0answers
14 views

Check if argument is empty (Problem Solved)

So below, I will go into detail on what I'm trying to achieve and if anyone can help me, it would be extremely helpful.
0
votes
0answers
14 views

Using a PHP form, get the page title or any other element in the sent e-mail

I am using a PHP form which I add in a page as a shortcode. I would like the user that receives the e-mail to also receive some indicator of the page the form was in...Is it possible to somehow get ...
-1
votes
0answers
12 views

Woocommerce related products sorted by date instead of the new shuffle filter

Recently woocommerce has this Shuffle filter woocommerce_product_related_posts_shuffle which always returns "true" and it randomizes related products. I want to sort related products by date (newest ...
-1
votes
0answers
21 views

Build a plugin for send/receive WhatsApp messages, which API? [closed]

I saw many plugin for use WhatsApp with WordPress and I'd to try to build my own, but I can't find any free API or PHP library... How do WhatsApp plugin work? How do the officiale API work?
0
votes
0answers
43 views

How to get a post's attached media (audio) ID and insert it into rtmedia shortcode

I am working on a personal project that is set up in a way that each post will have only one media file attached (wav audio) and no imagery or other media at all. I am using rtmedia to transcode the ...
0
votes
0answers
39 views

Trying to place a custom field after the total section in the checkout page in woocommerce

This code correctly works but does not place the custom field where I want it. In the add_action I would like to use woocommerce_review_order_after_order_total as the location attribute to place it on ...
0
votes
0answers
14 views

delete functionality wordpress

if($author_id == '1' || $role !== 'employer'){ //echo "hi"; exit; $titles_to_remove = array_diff($currenttitles, $Rstitle); //echo '<pre>'; print_r($titles_to_remove); exit; ...
0
votes
1answer
20 views

Custom field in PHP file

im a beginner with PHP, so i hope that someone can help me solving this issue. I want to display the expiration date of a post with the following plugin https://wordpress.org/plugins/advanced-...
0
votes
0answers
19 views

Display attached images of a page or post that are insetred using gallery

I've finally added a custom metabox to link some images to some custom urls, (thanks to the Sally CJ for the help in troubleshooting my previous issue with adding a metabox), I need now to adapt this ...