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.

0
votes
1answer
27 views

Run a code only on theme activation only during first activation

function clearwidgets(){ //stuff here only runs once, when the theme is activated for the 1st time } register_activation_hook(__FILE__, 'clearwidgets'); And the code I am trying to execute is this:...
0
votes
2answers
528 views

Array to string conversion error in PHP 7.2 when returning user role as class

Disclaimer: I'm rubbish at PHP, so please bear with me as I'm still learning. I'm getting the PHP error Array to string conversion for the following code: function osu_add_role_to_body($classes = '') ...
0
votes
1answer
686 views

Magento and WordPress URL integration

I'm in a bit of a conundrum. I've integrated WordPress into my Magento site, currently by a subdirectory. Check it out: http://vapetropolis.ca. If you go to the "reviews" section, you'll note there's ...
0
votes
1answer
502 views

show desktop version of website if button is submited

Hello i can't solve my problem. When users is on mobile device and click on "show mobile version" or something like that it will show him desktop version of web and if he click again switch back it ...
0
votes
0answers
13 views

How does one make a URL return dynamic JSON with custom Content Type?

Some background first, I'm trying to follow the directions here: https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/...
1
vote
1answer
697 views

How to Remove Parents Category Permalink from Posts

Simply speaking i want to do something like this. http://example.com/parent-category/child-category/post-name change into http://example.com/child-category/post-name I found some solutions, but ...
0
votes
1answer
560 views

Pagination shows Same posts

I made a custom template and I want to show all posts from certain category in this template excluding some ,I am getting as per desired but pagination shows same posts whether I am on 1st page or ...
0
votes
0answers
11 views

Wordpress css menu MOBILE

Menu Mobile not open submenu wordpress. Think there is a mistake in us CSS PHP CODE: <li class="list-open"> <?php wp_nav_menu( array( 'menu_class' => 'mobile-list', '...
0
votes
1answer
27 views

Collect all events in one year

Hello can you help me I can't do this: 2018 event 1 event 2 My current output: 2018 event 1 2018 event 2 I want do this without GROUP_CONCAT() ...
0
votes
1answer
12 views

custom-header not working

I have set the add_theme_support('custom-header', $defaults); in the functions.php file. It shows up in the customiser but when I add an image it does not appear in the preview or the live site. My ...
0
votes
1answer
27 views

ACF: Hide a div or template section when a custom field (in a field group) is empty

I am currently trying to get a div or section of my template to hide or not display when a custom field on the backend is not filled in. The problem is, what works for single custom fields that are ...
0
votes
1answer
577 views

WP Cron job timeout issues

I have to run a php function for around 10 minutes. Now I am sheduling the job as a wp-cron-job. But it is getting timed out after 30seconds which is the maximum execution time for php. How to get rid ...
0
votes
1answer
506 views

Commas not displaying in implode

I'm trying to separate some taxonomy terms with a comma, but I can't see to get the commas to show correctly. Here's what I got: <?php $terms = get_the_terms($post->ID,'type'); foreach ( $...
0
votes
1answer
7 views

Need to forward Data from WooCommerce Webhook sent to same site Wordpress REST API custom endpoint

I created a Wordpress REST API custom endpoint to be used as a Webhook URL in WooCommerce in order to convert the received data and then send it to a third party system, but the endpoint apparently is ...
0
votes
1answer
569 views

get_post_meta not work in php foreach

i have these codes : foreach ( $ids as $idss ) { echo get_post_meta($idss, 'IMDB', true); } i have search box with Form element that search and find all id ( $ids ) of searched word . i want to ...
0
votes
0answers
4 views

Google Currency Converter [on hold]

How do I make this currency converter work? By the means of the Google API function convertCurrency($amount, $from, $to){ $data = file_get_contents("https://www.google.com/finance/converter?a=$...
0
votes
0answers
12 views

Get related products based on subcategory from specific category

Hi I want to display related product in single product page, at the moment it show products that categories selected in current product. I just want related product have related based on "subcategory" ...
0
votes
1answer
20 views

Defining constant in a plugin to use in another plugin

I am wondering if this is possible or if there is another, better way, of doing things. Google-foo didn't help. So, I have two plugins, aa-frontend and aa-site. I need to define a constant or ...
0
votes
0answers
14 views

PDF generate from custom page [on hold]

I am on a way to build a website in wordpress. For registration purpose, i have created a custom page. I need to generate a pdf after the form submission. How can I make it? can anyone help me?
0
votes
0answers
10 views

After Convert HTML website into WordPress .xml file is not found in url [on hold]

After Convert HTML website into WordPress ror.xml & sitemap.xml file is not found in url.
1
vote
0answers
17 views

Fresh Install WP error - “The site is experiencing technical difficulties”

Usually this kind of error is associated with some plugin, but not in my case since this is a fresh install of the latest WP version. I'm getting this error after I uploaded all the files and ready to ...
0
votes
1answer
25 views

How to show order data by multiple ID?

I use the code. <?php echo '<table> <thead> <tr style="font-weight: bold;"> <td style="width: 50%;">Название<br>Сумма взноса</td> <td style="text-align: ...
0
votes
1answer
544 views

Debugging WordPress with xDebug

Until now I was using a local WordPress project and I was able to define the xDebugger in the php.ini file, it's very useful and helpful. But now I'm connected to a remote server and I only have the ...
0
votes
0answers
10 views

Checkbox that saves real-time value

Please help me as I create a checkbox that saves the value in real time and that appears on all pages if clicked or not. From already I thank you Sorry bad English <div class="toggle"> <...
3
votes
2answers
110 views

First wordpress blog, should I make my own theme for maximum customizability?

I am, although still extremely n00by, a semi-competent web designer and developer and I have decided to start a blog. I have heard all about this WordPress phenomena and I am really excited to give ...
0
votes
1answer
25 views

Get related product based on subcategory selected from category id with ID 142

Hi I want to display related product in single product page, at the moment it show products that categories selected in current product. I just want related product have related based on subcategory ...
0
votes
2answers
816 views

How to make multiple admin pages for one plugin?

I am trying to implement a simple login inside my plugin following this tutorial. I have successfully implemented the login inside a WP admin page, but I can't seem to redirect it to index.php. Also, ...
7
votes
1answer
37k views

How to get Woocommerce order product info

I am trying to get all woocommerce orders and find info about the products in each order. I have seen many examples on here and elsewhere on the web and they all seem to say to do the same thing but ...
1
vote
2answers
496 views

Getting movie and serial on actor page

I'm building a cinema site, I came with a problem, let me explain: Movies- are stored in Post's Actors- are stored in Post Type - persoane ( taxonomy= lista) Serials - are stored in Post Type - ...
0
votes
1answer
18 views

WordPress loop by meta key that is an array? and how loop multiple arrays

How can I get loop of posts by meta values that save in a meta_key that is an array like that $sharedHosting_plans_fields = Array ( ...
0
votes
1answer
521 views

Dividing the loop to style post differently

I'm using a plugin that displays post and shows them in a certain area on my site, such as the sidebar or anywhere i put the <?php;?> code, but only if the author that is writing the post clicks ...
0
votes
1answer
504 views

How do I create a single Wordpress page that will use PHP to include different HTML files based on a vaule in the URL?

I have used PHP on a page to include HTML files on a page such as: <?php require("http://www.mysite.edu/_sports/static/season_box.html"); ?> This works well for including a single file that ...
0
votes
1answer
529 views

How to add aria role and schema markup to custom walker container

Edit: after doing some research I've found that in the wp_nav_menu function uses the following code to display the containers value. if ( $args->container ) { /** * Filter the list of ...
0
votes
0answers
31 views

Migrate a normal website to Wordpress

recently I decided that I want to move my website with custom CMS to WordPress. I was wondering if there is an automation tool to help me with that process. I have already made the design and I just ...
0
votes
0answers
32 views

Can't update or install plugins in WordPress, php unidentified index

I just installed WordPress 5.2.1 on my new server. My server is running Windows Server 2019 x64 and IIS 10. I am running php 7.3.6. I have everything installed correctly and running. I have also ...
0
votes
1answer
25 views

Why my Ajax events are no longer detected after dynamic change of shortcode content

I have two input select (dropdown) in the content of my shortcode. The first is created when initializing the shortcode content, while the second is created when the user chooses the value of the ...
0
votes
1answer
27 views

How do I get my Javascript scripts working?

I am reading through the developer site for Wordpress and am just at the beginning of my learning of it. I have gotten my CSS to work via the wp_enqueue_style() but my javascript won't work via the ...
-1
votes
0answers
21 views

Using functions.php to hide the `From Our Blog` in WordPress menu page

I'd like to remove the from our blog on the WordPress menu page using php. Is there any way of doing it in functions.php? Tried. add_action( 'wp_dashboard_setup', 'bt_remove_dashboard_widgets' ); /*...
9
votes
2answers
453 views

Inconsistent temporary 404s on whole install | PHP error with post-template.php

I'm deeply confused by this one: I have a WordPress install on a Media Temple GS [one of many which work fine and are configured almost exactly the same] which is occasionally giving me 404s sitewide. ...
0
votes
1answer
39 views

Show subcategory name selected in specific category woocoommerce

Hi basically I have categori ID number (134) that has 2 child of that (red and blue). I selected the blue one. I want to display only the selected one (blue). But at the moment the show all ...
0
votes
1answer
926 views

Automatically create a loop for post ID

I am having trouble generating a loop for my post. The JS calls the slide_ID which then needs to display each slide-ID in numeric order for it to work. Example for slide-1 to scroll to its next slide ...
0
votes
1answer
541 views

Wordpress on AWS with ELB

The plan is to install wordpress on AWS with ELB. So far I have two instances of Ubuntu 16.04 each with PHP7 and both connected to RDS (MariaDB). The PHP Session is shared between the ec2 instances ...
0
votes
0answers
11 views

Show the subcategory name based on current product

Hi I can display subcategory name in current product page (single product page) but it showed all the subcategory name. I just want to show subcategory name based on the product selected. I have one ...
0
votes
1answer
17 views

Wordpress AJAX PHP(html) file that is within Wordpress Loop

I have a Wordpress AJAX call that is working in as much as it is able to get raw data from a PHP file. The AJAX is using the admin-ajax.php file. However, the PHP file I need to get is within the loop ...
0
votes
0answers
11 views

Add Product Permalink Before Order Item Meta

I am using the following code to add product permalink in woocommerce admin order page- function fpd_custom_order_item_values($_product) { $url = $_product->get_permalink(); echo '<p&...
0
votes
1answer
23 views

Change upload URL by mime type

I'm working on a site that has several hundred pdf files uploaded over the course of a few months. All uploads are organised in the uploads directory by year/month. The client has just decided they ...
0
votes
1answer
17 views

Change Login or Logout text based on status

I'm trying to display text in a button in the header that says "LOG IN" or "LOG OUT" depending on the visitor's status. The button calls a slider action, so I just need to change the text displayed on ...
3
votes
1answer
776 views

How to Join two tables from separate databases within Wordpress

Using wpdb to connect to a separate database I have connected to my other database with this code $mydb = new wpdb('username','password','database','localhost'); Now I need to do a Join of a table ...
0
votes
0answers
11 views

How can display image on woocommerce product page?

i already have code written but didn't know how can link my image with this function listify_cover( $class, $args = array() ) { $defaults = apply_filters( 'listify_cover_defaults', array( ...
2
votes
1answer
21 views

How to Add a Link to the Drop-Down User Menu in the Admin Bar?

I need to add a link to the drop-down user menu in the admin bar. Is there a hook or function for this?