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

How can I grab a published but editing-in-progress page's permalink in Wordpress?

I've tried invoking get_sample_permalink_html, get_preview_post_link, and quite a few others to try to pull out the link shown here. I want to print it to the error log. However, nothing shows. How ...
0
votes
1answer
11 views

Why can't I connect to the wordpress install page with Nginx?

I'm a newbie of WordPress. My environment is Ubuntu 18 + Nginx + PHP 7. Following the tutorial(https://www.myfreax.com/how-to-install-wordpress-with-nginx-on-ubuntu-18-04/), the wordpress directory ...
0
votes
1answer
16 views

Display a custom name when the user has no name settle in his account

I'm creating a code that shows the First Name for logged in users, using a shortcode, but I noticed that if the user has no name settle, it will display a blank space. How can I set a custom name to ...
0
votes
0answers
10 views

Set a numeric range for post ID generation based on post type?

I'm wondering if there's any way to configure WordPress to assign post IDs like so: Pages ID range: 10000 to 19999 Posts ID range: 20000 to 29999 Custom post type 'A' ID range: 30000 - 39999 Custom ...
0
votes
2answers
817 views

Create dynamic content from one WP page to multiple other pages

I want to create dynamic content that is taken from a specific paragraph from one page and writes to a paragraph on multiple pages that feature that same content. I am new to PHP and not sure how to ...
0
votes
2answers
20 views

How to replace file_get_contents() with a Wordpress Filesystem call

I'm using the PHP file_get_contents() function to retrieve and echo the contents of an SVG-file. <?php echo file_get_contents( get_stylesheet_directory_uri() . '/assets/images/Search_Glyph.svg' ); ?...
0
votes
1answer
949 views

How to change query string with pretty URL in WordPress using .htaccess file

I want to create a SEO friendly URL in WordPress, i am developing a site in WordPress it has several custom pages with custom PHP Script. I am sending data in id="some text" and matching this text ...
0
votes
0answers
10 views

How to change $defaults in Genesis' genesis_register_widget_area? [closed]

I'm looking to edit the defaults in the following Genesis Framework widgetize.php code. Specifically I'm changing the before and after title html. function genesis_register_widget_area( $args ) { ...
0
votes
0answers
16 views

wp_update_post gives 500 internal error

i'm editing a wordpress plugin and im trying to call a function within the thank you page, and in that function it has wp_update_post function to change the status in the database, the function works ...
0
votes
1answer
20 views

Having trouble creating two shortcodes, one for logged in user and one for visitors

So I'm trying to create a code (in functions.php) that displays a widget content, from shortcode, based on whether the user is logged in or logged out (visitor). I am successful in displaying content ...
-1
votes
0answers
15 views

HOW TO FIX Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE), [closed]

Here's my code <?php $sql = "SELECT * FROM categories WHERE parent = 0"; $pquery = $db->query($sql); ?> <nav class="navbar navbar-default navbar-fixed-top" id="...
0
votes
0answers
13 views

How can I add state based on shipping charge without using zipcode/postalcode?

I have a woocommerce website in UAE.This want to show state select in billing and shipping when customer checkout page show shipping price. It means duabi- 20aed and abu dhabi 30. My current website ...
0
votes
0answers
10 views

Pages from admin dasboard missing after site migration

i migrated a site which was hosted on wp-engine to my local machine, after the migration in the admin dashboard i saw most of the pages are missing. on the wp-engine server, there are 59 pages, but ...
0
votes
1answer
672 views

Display PHP within HTML values

What is the correct way to display a value in a link using php? The (Advanced Custom Fields) php works correctly outside of the html. Book on Expedia.com <a class="alignright" href="<?php ...
0
votes
1answer
15 views

Display all categories including sub categories under a list ul

This code is displaying only categories, how can I change to also include subcategories. Thanks Thanks, with this code is listing all together, I want that shows like this Category 1 ...
1
vote
2answers
574 views

CSS from textarea in options page to frontend what to do

I have a textarea for small css enhancements on the plugins page i output them directly to the head. My Question is how to sanitize the CSS i have validation function registered for the options with ...
0
votes
1answer
25 views

Form search query - displaying ACF “Post Object” field as results

I will try to summarize as simply as possible my request. I have a custom post type (CPT) called “job”. This custom post type includes 3 fields : The title (the native wordpress title field) / ...
-1
votes
0answers
15 views

Can we use multiple message fields in wp_mail() function?

I have a code that is not working for wp_mail() . I tried to debug it but was not successful. Here is my full ode in PHP <?php /** * Template Name: Order Form Page * * @...
0
votes
0answers
24 views

<DIV> being repeated twice - No explanation?

So I have an extremely strange thing happening. I am trying to properly layout my checkout page using Bootstrap's Grid framework. All seems good, except for in the payment method section. When trying ...
0
votes
1answer
18 views

Notify the user by e-mail after the creation of a post

I've a button, where the user create a post after click it. I want to notify him just after 10 min. I don't know the best way to do this with PHP. I know how to send the email, what I don't know is ...
39
votes
6answers
100k views

how to get page id of a page using page slug

Im pretty new to wordpress and I was wondering if I could get a page id with it's slug. Is it possible please let me know.
0
votes
0answers
22 views

is_user_logged_in returns false when I access certain pages

I'm working on a single page application built with WordPress and Vue.js, I used add_rewrite_rule to redirect all sub-pages of projects/ to index.php. Only logged-in users can access the application. ...
0
votes
1answer
10 views

Woocommerce - get_items() returns empty array

I am trying to write a function that will allow me to add product meta tags as additional order notes. Unfortunately, nothing works. After a few hours I decided to bring the function to the simplest ...
1
vote
1answer
832 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
0answers
12 views

add_post_meta - datas remains stored in the database [closed]

I use Formidable Form plugin. I need to get last name and first name author from single page to display these datas in form with Formidable Form plugin. To display these datas in my form I can use the ...
0
votes
0answers
27 views

How to set img attributes directly on the database instead of on the fly

How to set the attributes with proper dimensions directly on the database instead of on the fly using a this filter Insert width & height attributes to all images displayed on each page My ...
0
votes
2answers
19 views

WP Hook Before a post is created

I want to create a new user when a post is created from the back end. Is there a WP Hook that calls before a post is created. Thanks
0
votes
1answer
15 views

Show data obtained from a function and place it in a shortocode function

I'm new I need to put a value obtained from a function and put it in my shortocode function if you can help me thanks $a=4; // value obtained from another function my_function($a); function ...
1
vote
0answers
18 views

Sort the result of the main Query in shop page by a custom taxonomy

In a WooCommerce site, we have products that have a custom taxonomy that are assign to a region. When the user visits the site, we activate the browser geolocation, and we assign the user a region in ...
-1
votes
0answers
21 views

How to do a contact form plugin for wordpress [closed]

How to include my contactform files right in my php plugin code.
0
votes
1answer
660 views

How to override html codes in wordpress?

<article id="post-<?php the_ID(); ?>" <?php post_class( array('list-article', 'clearfix') ); ?>> <div class="list-article-thumb"> <a href="<?php echo esc_url( ...
0
votes
0answers
11 views

Site cannot access external connection

my WordPress site cannot access external connection (e.g. cannot browse/update plugins using dashboard - manual zip install only). The site is can be access from the outside world (via domain name) ...
1
vote
0answers
21 views

Automatically create child pages and grandchild pages when saving a (parent) page

I have a bit of a tricky one... I have a hierarchical Custom Post Type ('shows') that represents events. Is it possible for the user to create a new page (ie show), save the page and for Wordpress to ...
0
votes
1answer
23 views

How to limit the number of custom posts certain users can publish in Wordpress using php script?

Background: I tried both https://wordpress.org/plugins/bainternet-posts-creation-limits and https://wordpress.org/plugins/limit-posts/, but they didn't work for some reason with my custom posts. So I ...
0
votes
0answers
17 views

Get posts that are parents which don't have any children with WP_Query

I have a hierarchical custom post type which has posts with no children and also posts that have one or multiple direct children (only up to a depth of 1, i.e no children of children). For example: ...
0
votes
2answers
777 views

How to exclude a widget from W3 Total Cache Plugin

I am using a currency widget to show live currencies for different countries. I also use W3 Total Cache plugin and the widget data is cached. For example yesterday's prices are shown for today and I ...
0
votes
0answers
14 views

PHP Warning: A non-numeric value encountered in

I am currently getting the "PHP Warning: A non-numeric value encountered in" on two lines of a Wordpress plugin I am using... Here is the code from the plugin that is causing the issue ...
0
votes
1answer
17 views

location lock wordpress website

Hi I am setting up a WordPress website for a venue. I need to lock the latitude and longitude of the venue so that the website only open inside the venue, i tried setting it up on local host to only ...
0
votes
1answer
671 views

Sort by multiple options in custom field

With use of the Advanced Custom Fields plugin I created a select dropdown which contains 6 membership types. All of my 'listings' using this custom field are assigned one of the 6. I'd like to ...
0
votes
0answers
14 views

MyListing + WCFM - Change path on click (redirect?) [closed]

Im attemptng to tweak MyListing and WCFM so they can play nicely together but im having some trouble. The main issue is that when a user has registered and created a listing it creates the url domain....
1
vote
1answer
20 views

How to implement Google Tag Manager?

Trying to use google tag manager. It requires code in the . I tried editing the theme for our website but its returning a white screen see the below code before I add Tag Manager echo '<body ...
0
votes
0answers
15 views

Call WP Rest-Api to GET /users/me returned NOTHING in console

I am trying to get the login details of my wordpress account via WP Rest-Api with Cookies Auth in the logged-in wordpress condition. However, when I run it through a web browser I do not get anything ...
0
votes
0answers
16 views

how can I restrict one (product category) so it can only be purchased with partial payment i.e mycred + PayPal [closed]

how can I restrict one (product category) so it can only be purchased with partial payment i.e mycred points + PayPal (70% points + 30% currency ), rest of the product categories can be paid by 100% ...
0
votes
1answer
17 views

Plugin use of ajax/jquery depending dropdown

i am looking for an example on which implements two depending dropdowns. There are a zillion examples on the internet but they are not working within wordpress plugin. So this is what if have In the ...
0
votes
1answer
647 views

Using admin-post.php for admin form but it directs me to admin-post.php white screen

I'm using admin-post.php to handle a form submission on the admin side of a WordPress plugin I'm building. I have my form set up in a function like this: function display_charge_customer_input() { ...
2
votes
1answer
751 views

Rewrite sub folder dynamically with country code in WordPress using PHP

I know this question has been asked so many times but I didn't find any working solution or example which I can use to fix my problem. I have been working on a client site. There are two similar ...
0
votes
1answer
43 views

Conditional Fields depending on checkboxes

I'm currently trying the following (simplified objects): I have a bunch of "objects", which are cities. Each city has a relating country (even though I'm not sure how to implement this relation, yet),...
0
votes
0answers
10 views

WordPress Pagination Issue, displaying first page only

I have searched and can't find a solution that is working. I have this exact code on another site and it works. Not sure why it's not working here. All it's doing is ever showing the first page of ...
0
votes
1answer
12 views

How to pass a variable to get_template_part that's updated every time the template part is called?

I have a loop and in that loop I use a get_template_part to call the HTMl for the post to display. I also have a variable (number) to which +1 is added every time the loop runs. In this way I can ...
1
vote
1answer
23 views

Replace word in “the_content” only for index.php

I have some posts with video tag that contains autoplay (they should autoplay when you access the post page). I am using the the_content to show these videos on index page. The problem is that when ...

1
2 3 4 5
179