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
1 answer
4 views

I have a php function with a shortcode to add share buttons, but I'm having an error!

I use a php function to create and add share buttons to specific places through a shortcode. It work's fine, but I'm getting this error: Warning: Array to string conversion in ...142-custom-shortcodes....
0 votes
0 answers
6 views

Can't make an external api call in php side of wordpress child theme

I'm new to making api calls in wordpress. I need to make an api call through the backend to a 3rd party api. I can't do it through the frontend because the 3rd party makes it so I get a CORS error and ...
1 vote
1 answer
748 views

Hide author from search results meta, still display date and categories

How can I hide just the author from the post meta in search results, while keeping the date and categories? I know I can use something like: .post-meta .author { display: none; } to hide the author ...
0 votes
1 answer
753 views

Importing demo data in Multisite

I have a multi-purpose theme, which allow to download complete demo site content/wordpress. Normally (www.example.com) it's perfect and run all demo request, last time i install a new wordpress ...
1 vote
1 answer
3k views

How to display only specific Error types in debug.log? No notices, warnings, etc

I can't find the right way to make it work. I tried many things, like putting this in wp-config.php define('WP_DEBUG', true); define('WP_DEBUG_DISPLAY', false); define('WP_DEBUG_LOG', 'wp-content/...
1 vote
2 answers
1k views

Image upload and download from front-end

I'm making a web app using wordpress, the app will include this library that will do some steganography operations. I need some help to understand how to implement a front-end image upload for the ...
1 vote
1 answer
1k views

Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied

When I load the content using ajax it doesn't apply MediaElements.js to my audio player, so the audio isn't display. I think this is because the MediaElement.js is loaded with wp-footer(), and this ...
0 votes
2 answers
2k views

Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test

I've been trying to grasp AJAX for the past 12 hours and i'm slowly losing it. How can I simply pass two basic input dates via form or any other means, not refresh the page, and have it execute the ...
0 votes
5 answers
931 views

Can we have a php "page" without a WordPress "page"?

Somewhere off of the homepage we need to show a container page which does some stuff with custom post types. Actually it doesn't matter what it does, my point is it needs to exist and be reachable ...
0 votes
1 answer
24 views

Duplicated WP Multisite for testing environment is redirecting to production site

My goal is to have a test.example.de testing environment for my www.example.de WP Blog. Sadly, the site is still redirecting me to the production-site. My subdomain is registered as a CNAME with a TTL ...
2 votes
2 answers
10k views

How can I get the page or post language when I use wpml? [closed]

I'm using WordPress MultiLanguage Plugin and I want to know what is the language of a specific element, page or post. I do have the id but I want to obtain the language.
0 votes
1 answer
2k views

How to optimize and reduce excessive database queries

After we have run our codes and is functioning the way we want, something else faces us in the future and thats speed and scalability. Example a blog site must query the database to pull blog contents ...
1 vote
1 answer
2k views

Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?

I am using this code to fetch my posts: <?php if ( get_query_var( 'paged' ) ) { $paged = absint( get_query_var( 'paged' ) ); } elseif ( get_query_var( 'page' ) )...
0 votes
1 answer
1k views

Populate select option with JSON file

I am having a problem with populating a select dropdown from a JSON file. I am modifying an existing plugin, and I want to include countries that we want to see to. The JSON FILE { "AX": { "...
0 votes
2 answers
28 views

Pre_get_comments and orderby comment_karma

I have ratings on a custom comment type that stores the ratings in the comment_karma meta of the comment. Now I want to pull up the comments for a specific user and sort them by rating. Here is what I ...
3 votes
1 answer
1k views

Foreach insert query the best way

Hi i've got this code which works fine but I think it uses a lot of server resources because execute a query to the database for each user id stored in a group, is there any way to solve this problem? ...
0 votes
1 answer
719 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
1 answer
709 views

Check if a user is logged into my WordPress site which is on a different server

If I have a file example.php which loads WordPress and checks if a user is logged in to my WordPress site: // Load WP require_once(dirname(__FILE__) . '/wp-load.php' ); // Check if user is logged in ...
30 votes
6 answers
14k views

Running WP-Cron on Multisite networks the right way?

I have WordPress Multisite with several sites. I set up DISABLE_WP_CRON to true in my wp-config.php. If we set up cron task with wget or curl we have 30 sec rule to execute PHP script. It's so small ...
0 votes
2 answers
700 views

custom url with custom post

I want to change my custom post URL. I want to remove "item" from URL. With the below code and with custom post type url plugin http://wordpress.org/plugins/custom-post-type-permalinks/ my URL is: ...
1 vote
1 answer
2k views

Fix 403 error on WordPress multisite network using subdomains

I've a WordPress installation that I've transformed into a multisite network. I'm using cPanel and I've followed all the instructions to configure the WordPress installation. I've set up the ...
0 votes
1 answer
925 views

Looping the data from WordPress database using foreach

I am trying to fetch data from the WordPress database table using wpdb and loop it using foreach statement so as to output results in select tag. I created a custom WordPress template and this was to ...
1 vote
1 answer
944 views

Removing "There is no account with that username or email address." error message in "/wp-login.php?action=lostpassword"

Would like to find out if there is any way I could customize the wp_login page to remove the "There is no account with that username or email address." validation (show below) and any email/...
0 votes
1 answer
1k views

How can I check that the acf field value is not a duplicate when adding a post?

I have a field in which I add the name of the record in the original language. And I translate the title into another language. When adding a new record, I need to check this field for duplication in ...
3 votes
1 answer
794 views

How to display related posts from parent category

I am using the following code to display the related posts but it is showing posts for that category only like brand showing brand posts only. What I am looking for is if I select any of the posts ...
0 votes
0 answers
15 views

Display posts based on the selected category when no subcategory is chosen

The following code displays posts based on subcategory. First dropdown is a custom taxonomy category, second dropdown narrows down the search to subcategories associated with selected category. My ...
0 votes
0 answers
17 views

Problem with custom user fields default value and retrieval

I created 2 custom fields for users on my site, a Company name and a checkbox for whether a user has download access or not. Here is the snippet for the functionality: add_action( 'edit_user_profile', ...
0 votes
1 answer
10 views

WPML posts_joins on translated items

I found a way to filter the search query so it goes though the product_cat title and description to look for a term and then display all the connected product. I am now looking for a way to make it ...
1 vote
1 answer
797 views

Meta inserted through wp_insert_post gets messed up

I'm extending the Woocommerce Product CSV Import functionality to import more data. I'm inserting a CPT with 2 metadata, a string (URL) and a bool, and the post_meta inserted gets messed up. It ...
1 vote
1 answer
2k views

Call a PHP Function with Multiple Parameters that is outside the AJAX Handler

Q: What is the correct way to call a PHP Function with multiple parameters from the AJAX Handler? Q: Am I calling the php function correctly? Q: Is there an easier way to do this? Page Element The ...
0 votes
2 answers
710 views

Conditional formatting on data fetched from MYSQL

I'm not an expert in PHP and I'm trying to apply conditional formatting on data fetched from wpdb. To be fair, I'm trying to create shortcode for this. My motto is to fetch values for $previous_marks &...
0 votes
1 answer
3k views

Using featured image of blog archive page

On my custom wordpress theme, I am using the featured image thumbnail for all of my pages to be the header of the page. I've created a page called "blog" and using it as the archive ( via ...
0 votes
1 answer
2k views

Woocommerce Related Product by 2 taxonomy

I need to change related product by taxonomy and if taxonomy didnt have enough product, display rest of it from other taxonomy. I have 2 taxonomy; product_tag and product_cat. Sometimes products in ...
0 votes
1 answer
24 views

Including product categories (product_cat taxonomy) title and description in search query

WHAT I'M TRYING TO DO I'm using woocommerce, but the question could work for WP categories also. When searching for a product, the search engine only looks for products info (title and description) ...
0 votes
1 answer
10 views

Show a text in menu

I am trying to show a custom text in menu. I am using below code on functions.php of current theme. add_filter( 'wp_nav_menu_items', 'add_search', 10, 2 ); function add_search( $items, $args ) { if ...
0 votes
1 answer
710 views

How to display 8 posts in four columns and 2 rows on a carousel slide?

I am trying to achieve a grid layout as such that posts will be visible on a carousel slider. Each slide will consist of 8 posts. 4 posts per row. I am using bootstrap as well. I want html to look ...
1 vote
1 answer
2k views

Wordpress shows error related to allow_url_fopen

I just installed wordpress with plugins, everything works find except on a 'contact me' page, where I can see an error like this. Warning: getimagesize(): php_network_getaddresses: getaddrinfo ...
1 vote
3 answers
3k 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 ...
1 vote
1 answer
1k views

WordPress load javascript file if something... (after the page is loaded)

I'm having an issue with making a website GDPR ready. It is loading a javascript file for InstraGram that is setting a cookie. I was able to locate where this file is loaded in the plug-in directory ...
0 votes
1 answer
28 views

#038 & wordpress Help

Please help me edit the code so that wordpress does not change the & symbol to #038 when I publish links on my site function esc_url( $url, $protocols = null, $_context = 'display' ) { $...
0 votes
1 answer
2k views

How can I update the price when someone enters postcode or zip code in woocommerce checkout page?

So, I am working with my custom plugin in which I need to get zip code or postcode on woocommerce checkout page and add my additional price and be done with the payment. I tried using AJAX, which get ...
0 votes
0 answers
8 views

Live Preview while customizing is not showing the updates while editing in WordPress

I'm working on a small website in WordPress, when clicking the "customize" button, it will open a page that shows a "Live Preview" of the website and allows you to add custom CSS ...
0 votes
1 answer
980 views

Need to Echo A Url path to show on a wordpress page

I need to extract a url path number to a shortcode... Here is an example below... https://example.com/page/c/1 I need the number "1" to be shown with a shortcode... [url_path_number]
0 votes
0 answers
17 views

custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget

basically as the title states, I am trying to output data into an Elementor Loop grid widget, using the infinite scroll pagination setting, however whenever I select an option that has only 1 post, ...
1 vote
1 answer
2k views

Access Child Class of Plugin Main Class Instance

In a WordPress plugin where the author has defined a parent class and uses a standard instance method for other plugin authors to access the plugin example: function WP_Plugin() { return ...
0 votes
1 answer
1k views

Changing ALT-tag for logo in wordpress

I've been working on a site for someone and I've been debating whether or not to take a risk with something. I haven't really worked a lot with .php in the past, but I know that a few mistakes in ...
0 votes
1 answer
1k views

Display Results of SQL Query on WP site

I hope this is not redundant - but there always seems to be enough different that I cannot get things working. I am building a function in my functions.php file - all other functions work fine. $query ...
0 votes
1 answer
908 views

Soflyy WP All Import Custom File Download Issue

I need to send a user id to a remote server to download an XML file. I accomplish this with the snippet below: function custom_file_download($url, $type = 'xml'){ $ch = curl_init(); $...
0 votes
1 answer
17 views

Help with coding a link for a button in WordPress with The Events Calendar Plugin

This is my first time asking a question on Stack Exchange. Sorry if I don't do it right. I'm using WordPress on a client redesign. They sell courses on their site using the Events Calendar plugin. ...
0 votes
3 answers
808 views

How to use $_GET function Wordpress backend

I use Plugin Boilerplate for my project. I searched the internet and read all the questions but I couldn’t find what I need. I also read the WordPress Codex. I think I couldn’t get the idea. I have ...

1
2 3 4 5
211