Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

-1
votes
1answer
46 views

Separate code and presentation HTML and PHP

I was told that I should have the scripts enqueued only when the shortcode is used also to prevent direct access (use die()) to plugin file and separate the HTML and PHP but for this function, I do ...
0
votes
0answers
10 views

Customer Count of last object of Totals is always 0 from Woocommerce sales report api [on hold]

I am using Woocommerce Offcial php rest Api library in my local Crm application. And calling Sales report data. $query = [ 'context' => 'view', 'date_min' => '2019-01-01', 'date_max' => '...
0
votes
1answer
18 views

How to get Post Type from the functions.php file

TLDR: How can I get the post type within the functions.php file? I am trying to add the following code only when the post type is a 'page' and not when it is a 'post.' However, I am not able to call ...
0
votes
0answers
9 views

Google Ads and Wordpress

I have a Wordpress site and I'm trying to use Google Ads. I have done the following: Created a conversion Created a tag I did this 21 hours ago. To install the tag, I used Google Tag Manager and ...
0
votes
0answers
12 views

Options API: Options does not save

My Settings wont save and I dont really know why. Here is my Code: <?php class STLI_New_Settings { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $...
1
vote
1answer
60 views

How to call function at the bottom of post using plugin?

I am creating a plugin and need to write a function which will invoke at the bottom of posts. Currently, I have a shortcode created and I'm calling the shortcode at bottom of each post wherever ...
0
votes
0answers
15 views

How to Automattically Regenerate Excerpt

I constantly update my posts, and one problem i face is that the excerpt is the first few words of the first ever version of my post. This means that even if i update my posts, to update the first ...
0
votes
0answers
12 views

How to create full background parallax page? [on hold]

I've been searching for a solution for a long time and can't find anything. I'm using the Flash Theme and what I want is to hide every background, except the background image. In the picture you can ...
0
votes
2answers
10 views

Attempting to add a checkbox to toggle display of a row in ACF [on hold]

I'm setting up a custom theme with pages that use flexible content to add content to the page. I'm wondering if there is a way to add a checkbox that will toggle the display of a repeater row (one of ...
0
votes
1answer
34 views

How to get current post category details inside “loop”?

I have a rather simple problem I can't solve. I have custom styling for my cards and one of the elements of the cards is the category, when I access the_category() from the Loop it comes with its own ...
0
votes
2answers
25 views

How do I stop my form from adding code to current page URL instead of re-directing. Been stuck for days

I am currently setting up a WordPress website and everything is going fine except for one issue I simply can't figure out. So basically I have a booking form on my website that allows people to ...
0
votes
0answers
8 views

Override billing fields with custom values defined in woocommerce_checkout_fields filter

I am trying to override the billing form values in WooCommerce with the following code in my child-themes functions.php: add_filter( 'woocommerce_checkout_fields' , 'checkout_field_defaults' ); ...
0
votes
1answer
15 views

How to create dynamic templates?

So let's say that I have a navbar template with the following content: // template_parts / navbar.php <nav class="navbar navbar-expand-lg dark bg-transparent fixed-top" id="mainNav"> <div ...
0
votes
1answer
17 views

Can't upload CSV file to plugin directory using custom upload form in admin panel

I need some assistance here. So far, i build a plugin, that are able to import data of a CSV file and parse it into fields of a custom post type. At this point, I would like to make a form to ...
0
votes
0answers
20 views

How to add Load more posts in category template

I want to add load more button for posts and limit the posts to 6 function cat_ajax_get(catID) { jQuery("a.ajax").removeClass("current"); jQuery("a.ajax").addClass("current"); ...
0
votes
0answers
15 views

Customizer control for including files in functions.php

I have the following include in my theme's functions.php file to add social sharing icons to my theme: require get_template_directory() . '/inc/social-sharing/social-sharing.php'; I would like the ...
0
votes
1answer
14 views

How to create an unordered list of images separate from the content

Some of the solutions I'd tried are 'multiple featured images,' and 'upload image gallery,' but they're either require plugins, are too convoluted, or make for terrible html syntax. I've looked ...
0
votes
0answers
14 views

Users list with Ajax Pagination inside each author profile for their follower and following users

I'm trying to create an followers/following users list for each user in their profile page with Ajax Pagination. Someone here was helped me to make the Ajax pagination working, but i'm facing a big ...
0
votes
1answer
32 views

Include a Gutenberg Block in a PHP file

Hi There Is there a way to include a Gutenberg Block in a PHP file? Example: I created a block named: posts grid, which is a block that displays the latest posts, the user could change the number ...
0
votes
0answers
18 views

ACF - Undefined Index on array

When trying to get a group of custom fields by ACF it returns an array as expected but when I try to echo the value of one of the items I get a undefined index error. The code: $faqHeader = ...
0
votes
1answer
16 views

How to count posts posts if they are in a separate content page?

I am using a content page to render elements from my "Loop", I would like to count the post to get my current position as this would determine the size of the card I display. My (html, css cards you ...
1
vote
1answer
7 views

Random order of WP_Query results with highest meta value

I need to random of cars with highest price. My code: $argsLoop = array( 'post_type' => 'cars', 'posts_per_page' => 12, 'paged' => 1, 'meta_key' => '...
0
votes
1answer
10 views

If is_page elseif is_page not working like I want it to

My code looks like this: if (is_page('mounting-guides')): $guides = get_field('guide_pdfs'); elseif (is_page('user-manuals')): $guides = get_field('user_manual_pdfs'); elseif (is_page('cleaning-...
2
votes
1answer
24 views

WPDB: how to get the value of a field in a custom database table

For my WordPress site, I would like to echo the value of a column in a row (determined by the user's ID) of a table in the database for my site. This table was created by a plugin so it is not ...
0
votes
1answer
19 views

Wordpress child theme, creating a custom php template page

I am currently working on a project that uses a child theme (storefront is the parent theme). I need to be able to code using pure php / javascript (outside wordpress admin). Other custom template ...
0
votes
0answers
11 views

Custom Code Review: non-numeric value encountered

I am getting a E_WARNING error on my child theme template for woocommerce/content-product.php Stack trace E_WARNING: A non-numeric value encountered in {closure} called at ? (?) in array_walk called ...
0
votes
0answers
21 views

How to make a slug from GET request to other page and then retrieve it as variable?

Let's say i have custom page site/wordpress/id/ How can i: Send get request to it the right way with form that has 1 input "id" what action should be in that form? Make it look like guest is on the ...
0
votes
1answer
19 views

wordpress dependent dropdownlist using post type is not working

wordpress dependent drop down list using post type is not working in ajax. I need a ddl value from another ddl in post type. i have 2 post type department and doctors, when i select a department in ...
0
votes
1answer
20 views

What's the best way to format ACF number fields for display on the front end?

I hired someone to help with this, and he had a javascript solution which he entered in the theme footer. I just added an html tag and it worked. However, it broke because he didn't use the child ...
0
votes
0answers
10 views

Can't Update ACF field with nodejs request [closed]

I'm trying to update an acf field with nodejs this is my nodejs code; var postData = {update : '1', field : 'acf-field-text'} var querystring = require("querystring"); var qs = querystring.stringify(...
0
votes
1answer
28 views

Workaround for: PHP syntax error, unexpected T_STRING in load.php on line 1104 (when installing)

I’ve received the error: PHP Parse error: syntax error, unexpected T_STRING in /web/www/html/xxx/wordpress/wp-includes/load.php on line 1104 trying to install wordpress on a linux server. ...
0
votes
0answers
13 views

user specific private content

I am creating a website for a courier at present. One thing I am keen to include in the site is an area where clients can log and view their invoice history, update their information and view POD's (...
0
votes
1answer
13 views

Child and Parent Pages list of sub pages

I have a parent page called services with children, each service child has child pages within it. On the first level child page i want to show all of the pages below it in. When i click through to ...
0
votes
2answers
18 views

Automatically updating page list

I'm building a WP website for a client that require location pages to be added on a frequent basis. I wanted to created a parent location page that would have the full list of locations that would ...
0
votes
1answer
18 views

Creating a functionality plugin to edit seriously simple podcasting

I have made the following change to the below file in Seriously Simple Podcasting Plugin: /wp-content/plugins/seriously-simple-podcasting/templates/feed-podcast.php The full file can be found here:...
0
votes
2answers
23 views

Display attribute on shop page after the title

I am using the following code for displaying a custom attribute on the Woocommerce shop page. But for some reason, the year is displayed above the product image instead of after the product title (In ...
0
votes
1answer
23 views

Warning: Use of undefined constant list_all - assumed 'list_all' (this will throw an Error in a future version of PHP)

I have a problem with php 7 syntax. I installed this plugin called simple table manager https://wordpress.org/plugins/simple-table-manager/ and upon activation I got these warnings Warning: Use of ...
1
vote
1answer
20 views

Databases - Submitting data from inputs to database [closed]

I am attempting to submit data to a table I have created within my database. For sanity sake I have called it 'wp_email_subscribers'. Including the wp_ prefix. I know there is a way to insert data ...
0
votes
0answers
11 views

How to output CMB2 select options from repeated groups select elements?

I've searched in previous posted questions but I can't find something similar (but if it's already posted, please let me know). I've got the following repeated group of fields, with a select in it: $...
0
votes
1answer
30 views

Allow Comments by Default for Multiple Post Types

I have this working for one post type, but need to do it for three. I tried the "else" statements but I realized I suck at PHP. function my_comments_open( $open, $post_id ) { $post = get_post( $...
0
votes
0answers
20 views

Post content, PHP help

I am having some difficulty displaying post data. I am entering my PHP into a PHP element of my front end page builder. All I want is the post title wrapped in an H4 tag followed by the post content. ...
0
votes
1answer
21 views

wordpress frontend editor to add extra css to website

i need to create a plugin that allows me to select any button or any part of the website and add extra css to it ,i have manages to consumer rest api within wp ,add menus and submit forms but i have ...
0
votes
0answers
11 views

Homemade global template, advice?

For the theme I’m using there is a hook for an area just above the footer section and here I would like to output different ”banner sections” that are ”prepared globally”. So for each ”banner section”...
0
votes
0answers
14 views

Top Authors list by highest post views with Ajax pagination

I'm trying to create an users list to sort all users by the highest post views for each user, I added $output = array_slice($topuser, 0, 10); to get 10 users when i click load more in the next page, ...
2
votes
1answer
94 views

Sortable admin column for one meta key with three possible meta values

I've looked over 2 or 3 similar looking threads regarding sortable columns and the meta queries involved with making them work. None seem to resolve my exact problem. I am using the pre_get_posts ...
0
votes
2answers
21 views

How php content after the first and second paragraph

You have used the code of this question (Show content after the first and second paragraph) and it works correctly for me. <?php $paragraphAfter[1] = '<div>AFTER FIRST</div>'; //...
0
votes
0answers
13 views

Save post meta save as multi dimensional array

I want to make portfolio page using meta field, where clicking to image opening image slideshows. So I want to loop main clickable image in array and images of slideshow as an array of main image, ...
1
vote
1answer
13 views

Add more button if more 8 items

I want to add a "more" button if more than 8 elements, I tried it <div class="under-menu__countries"> <span class="under-menu__title">Countries</span> ...
0
votes
1answer
30 views

Custom route and query

I am trying to use a custom WordPress route and function, but I am getting a route and function not found error. Below is my code but I am not sure where it is breaking: add_action('rest_api_init', ...
0
votes
0answers
27 views

Unable to update the meta boxes with multiple fields

I successfully build a function, that is able to import data from a CSV into posts of a Custom Post Type (CPT). I am able to parse data into the native Title and Description fields, but it fails, when ...