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
0 answers
12 views

Store category and product category not related when I use plugin of dokan in wordpress [closed]

I noticed that on the Dokan plugin, the store categories and product categories are not related, in other words, if a seller chooses a store category for example Electronics; when adding products to ...
user avatar
0 votes
0 answers
18 views

Using Ajax to submit a form, and run a SQL Select query based on user input from the form

I'm creating a web form on my WordPress powered website. The form is intended to allow the user to enter a ZIP Code (aka postal code). When the user submits the form, the page should query a MySQL ...
user avatar
  • 1
0 votes
0 answers
10 views

How to put search bar & logo in the "primary navigation" storefront theme?

I'm using storefront theme for my shop, and here's the header I wanna put both the logo and search bar in in inside the primary navigation as I explain in screenshot.
user avatar
  • 1
0 votes
0 answers
9 views

Automated Cart Update With Alert Box Each Time

New To PHP and, I am currently attempting to create a plug in that creates an alert box every time the quantity in a cart is changed. So far I have successfully implemented updating the cart ...
user avatar
0 votes
1 answer
37 views

Make PHP work with HTML tags

I have the required code for what I want <?php if ( is_singular() ) { <?php if (get_post_meta(get_the_ID(), 'square_image', true)) { ?> <img src="<?php echo get_post_meta($...
user avatar
  • 165
0 votes
1 answer
11 views

How to check post meta isset or not empty during publish/save post?

How to check if a specific post meta isset/!emtpy during updating or publishing a post ( save_post() )?
user avatar
0 votes
0 answers
22 views

redirect after submiting post for review

I have a frontend page that allows "Tutor Instructor" role, to create a course and this course is a custom type post called courses, when the Tutor Instructor finishes creating the course he ...
user avatar
  • 3
0 votes
0 answers
16 views

I can't start oauth xero start session in my plugin

I am trying to connect users xero accounts with my app and I have that problem Warning: session_start(): Cannot start session when headers already sent in /storage.php on line 11 my storage.php is ...
user avatar
0 votes
0 answers
23 views

Need to add a post’s featured image to a section on the frontpage

It looks like I will need to create custom PHP code for this and either add it to my includes directory within a custom PHP file, or to the functions.php file. I need the ability to use a featured ...
user avatar
0 votes
1 answer
20 views

How to redirect outgoing links via my own website

How can redirect outgoing links first to my own site? for example i got a recipe post and i got a outgoing link to another website this link is stored in a metafield $recipe_url = "https://...
user avatar
0 votes
1 answer
18 views

Wordpress Multisite login_redirect to primary blog and specific page based on role

I'm stumped trying to redirect my users to a specific page on their primary blog when they login to the root/main site on a MU setup. I have the site editors with a specific 'editor' role and then ...
user avatar
0 votes
1 answer
61 views
+50

Finding the screen id of a page generated with add_menu_page

I'm at a basic level of WordPress + PHP and I'm trying to build a pretty simple plugin. I've set up the plugin correctly, and the plugin page is generated with function wpplugin_settings_page() { ...
user avatar
0 votes
0 answers
17 views

Best practice for getting stuff like wp_head() without echoing it

So this question is related to this one I have WordPress with Twig and I need to include the return of wp_head in my head.html. However, wp_head() echos its contents, instead of returning it. Sure ...
user avatar
  • 101
0 votes
1 answer
17 views

Upgrade theme to be compatible with php 8.1

When I upgraded PHP from 7.4 to 8.1 in DreamHost, the site stopped loading. DreamHost support said that, "the error was caused by the theme in use (cityguide-child/ Parent theme cityguide) not ...
user avatar
0 votes
0 answers
45 views

How to exclude labels from certain categories in a shortcode?

Good afternoon. There is a shortcode [alltags] that displays ALL site tags on a separate page of the site in alphabetical order with a letter. function wph_alltags_shortcode( $atts, $content ) { $...
user avatar
  • 1
0 votes
0 answers
9 views

Output product category link from WP_Query

I have a WP_Query that outputs products from given Product category name. For each product list I would also like to link to the category of that product, but I'm not sure how. My query: <?php $...
user avatar
0 votes
0 answers
12 views

How to implement Polylang functions in my theme's php file?

I am translating a site with Polylang that was created by someone else using a custom theme. Some strings couldn't be found by Polylang, so I need to manually register them for Polylang to see. Now, ...
user avatar
1 vote
1 answer
43 views

Adding hreflang tags automatically in WordPress subdirectory multisite

We have a WordPress MU subdirectory network setup: www.example.com - main website, USA, global www.example.com/uk/ - to display for UK visitors www.example.com/au/ - to display for Australian ...
user avatar
  • 1,750
0 votes
0 answers
23 views

Pagination at category doesnt work with same name of page

i have a problem with my pagination but only at category page. I'am not developer, and i try fix it from few days. My pagination working if i make different name of pages for main BLOG, and category ...
user avatar
0 votes
0 answers
23 views

How to pre-query and compile post objects in php for Wordpress

I'm building a site with a heirarchy of posts types. Artists -> Releases -> Versions. Artist is the grandparent post type of versions. I've created the post type heirarchy in Toolset Types ...
user avatar
0 votes
1 answer
30 views

Best way to track Price Development in Wordpress? [closed]

Hey i wonder what is the best way to Track price development of a product in Wordpress? In my case, posts representing products and the price is stored in a metafield. The wordpress site got over 10....
user avatar
0 votes
0 answers
23 views

Hot to check if new posts have been published since page load and notify online users?

I want to show a div notifying online users that there are new posts since they have accessed the page, in the index and also if new posts have been added in the category or tag they are browsing. I ...
user avatar
0 votes
0 answers
14 views

Error with automatically updating Wordpress in Plesk

Plek tries to update my Wordpress but gives this error. Does anyone know how I can reset the cache, or have an other solution? 1. Website "Domain" (https://www.domain.nl): Failed to reset ...
user avatar
  • 101
0 votes
1 answer
23 views

How does add_option() function enable action hooks to fire right after actiavtion?

The documentation page says that the hook process performs an instant redirect after it fires. So, in order to do something right after the activation the page suggests using add_option like so, ...
user avatar
0 votes
0 answers
21 views

Unzip file in functions.php, and add it to cron

I have a file in the root folder of my wordpress installation (myfolder, wp-content, wp-config, and all other). I want unzip a test.zip archive in my myfolder folder in root directory. I try this ...
user avatar
2 votes
1 answer
34 views

Javascript code inside "<# #>" in core WordPress files .php

I found some interesting embeding JavaScript mix with HTML in WordPress php files, for instance: <?php // Template for the Attachment Details two columns layout. ?> <script type="text/...
user avatar
0 votes
0 answers
8 views

Nav Walker that shows only children and siblings of top level parent menu item

I have a nav menu that is structured like this.. Main Section 1 – Child Link 1 -- Grandchild Link 1 – Child Link 2 – Child Link 3 Main Section 2 – Child Link 1 – Child Link 2 – Child Link 3 Lets say ...
user avatar
  • 101
2 votes
1 answer
98 views

Find variables available at a given hook

I'm hoping for a simple way to tell/find/echo what the available arguments are available for use at a given hook. For example — function example_function($something){ //do stuff with $something ...
user avatar
  • 123
0 votes
0 answers
13 views

Change permalink structure specific category

I have a specific category that all posts that are in that category must follow the following structure: category-name/child-category-name(if any)/post-name The other posts will remain with the ...
user avatar
0 votes
1 answer
21 views

Adding onload to body for certain pages

I am looking for a function to add <body onload="prepareFrame('https://airtable embed URL here')"> to certain wordpress pages only. I know how to add a custom body class but not an ...
user avatar
  • 688
0 votes
0 answers
22 views

Add posts to custom table in database instead of wp_posts

What the code does: Imports posts, loops through all the posts and calls wp_insert_post to create a new posts for each import. Objective: Import posts and store them in another table, not under the ...
user avatar
  • 177
0 votes
1 answer
47 views

How to pass username in affiliate link in wordpress website

I need to pass current logged in user in wordpress website as SUBID in the affiliate link as follows. Affiliate link format is like below. https://affiliatenetwork.com/track?id=myuserid&url=https:/...
user avatar
0 votes
1 answer
24 views

how to get serialized post meta

I have posts that have video content and these videos stored in database like this (serialized) a:1:{s:9:"video_url";s:0:"";} This serialized data have post video urls but can ...
user avatar
0 votes
1 answer
17 views

How to remove the two duplicate values

How to remove the two duplicate values Example I have the variable 1 $help_brother: $help_brother = '30,45,12,13,14,15'; And the variable 2 Force World: $force_world = '45,12,15'; The result must be:...
user avatar
0 votes
1 answer
25 views

Hide Heading if ACF Field is empty

I am trying to add a "Local FAQ" section to all the individual location pages on a site with literally thousands of individual location pages. I am doing this by using ACF field in the ...
user avatar
0 votes
0 answers
17 views

Additional file upload in Gutenberg page options/featured image

I would like to add an additional image upload in the featured image part of the Gutenberg page options editor. e.g. as in the image below, but with an additional file upload area. In my PHP file I ...
user avatar
0 votes
0 answers
12 views

I want to include a particular word into the excerpt of every posts of a custom post type. How can I do that pragmatically?

I want to include a particular word into the excerpt of every posts of a custom post type. The custom post type "movie" has thousand of posts. It is not possible to manually edit the excerpt ...
user avatar
0 votes
0 answers
15 views

save_post trigerred twice

I am trying to add more functionality to the update button. My end result is that I wish to call a python script but for now I am messing around with writing a log file. This is resulting in the log ...
user avatar
  • 1
0 votes
1 answer
38 views

Scheduling an event inside plugin class is not working

wp_schedule_single_event is not firing. I wrote a function that is posting to external API, if it failed I schedule the same posting function to run 5 seconds later in cases of timeouts. Here's the ...
user avatar
  • 96
0 votes
0 answers
14 views

Disclaimer that will show every refresh of the page

Hello I have here a code that is based on a "where you first access the page you will see the Disclaimer template" but I want it to show every time I refresh the page <?php // ...
user avatar
  • 1
0 votes
0 answers
8 views

Change Dropdown jQuery to show/hide but with default place holder that shows all

How to set the jQuery so if default "Department" is selected show all, and only hide all else one other section made. for example, if non selected will be "Department", if "...
user avatar
  • 105
0 votes
1 answer
24 views

How to remove the message 'We could not find any results for your search' without changing template files and without adding posts/pages?

I take the question back with context. The goal is not to add posts or pages so that the post is replaced by the title of the post/page. The goal is not to modify the search.php file to remove this ...
user avatar
1 vote
1 answer
54 views

Escape when echoed

I've been trying to submit a plugin for review and I keep having problems with the echo line. The last version I sent was like this. <option value=""> <?php _e( '- Default', ...
user avatar
  • 15
0 votes
0 answers
27 views

Download file and redirect to page or vice versa

I have a Wordpress site with a custom post type called downloads. The post type has a file field added to it with Advanced Custom Fields (ACF). The downloads post type is used for download links ...
user avatar
  • 101
0 votes
1 answer
27 views

Programatically upload a file to be stored inside blob field in database, NOT on filesystem

old php developer here, very.. very new to WP, so be kind. As part of a plugin, I am trying to allow files to be uploaded with the intended destination storage in a specific table. I have the ...
user avatar
0 votes
1 answer
17 views

How to set a template with wp_insert_post

I'm trying to set my template to the Elementor Canvas when using wp_insert_post but it isn't working. It is creating the new page fine but not using the canvas. What am I doing wrong? { "action&...
user avatar
0 votes
0 answers
24 views

Password protect URLs

I have a Wordpress site set up with download links that either could be set as external URLs or links to media items uploaded to Wordpress. I would like to password protect these, so clicking a ...
user avatar
  • 101
0 votes
0 answers
62 views

Woocommerce. Get a list of products in the current category on the archive page and product page

I'm trying to create a small code that will display a list of discounted products that belong only to the category of products that the user is on, that is, if the user is on the clothing category ...
user avatar
0 votes
0 answers
46 views

AJAX function running TWICE with WordPress admin-ajax.php

I have a form submit event that calls a WordPress ajax function. The form submit event occurs only once (It is correct as expected). But the ajax function loaded TWICE (expected to occur once). Here ...
user avatar
  • 11
0 votes
2 answers
80 views

Wordpress Custom SQL Table with UserID Filter for results

UPDATE: I have realised that I need to use a plugin like PHP Snipping or Insert PHP to make this work, I have updated my screen shots to reflect where Im upto from my research. The code is working and ...
user avatar
  • 3

1
2 3 4 5
200