2022 Developer Survey is open! Take survey.

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

Contact Form 7 Wordpress, checking a few fields, if empty then invalid

Could someone help me to solve the problem. I would like the system work like bellow. If both fields are empty = invalid. If any of the fields is completed = valid add_filter('wpcf7_validate_text', '...
user avatar
  • 1
0 votes
0 answers
10 views

WordPress get last inserted user id

I want to disable user_login field into my CMS. They are register only their email adress. I think to create secret user login by programmatically. I think for accessibility and manageability also I ...
user avatar
  • 258
0 votes
0 answers
12 views

Multiple Shortcode Creation In Functions.php Using Else,ELSEIF [closed]

Please excuse my ignorance! I almost don't know what I'm talking about. Our website currently has php written to create shortcodes that pulls data (forum posts) based on when it was posted for a ...
user avatar
0 votes
0 answers
4 views

Dynamically added custom fields not displayed on WooCommerce email notifications

I have a different kind of scenario then the typical custom fields (I suppose). I am not getting custom values (fields) from user in the form rather I have an implementation which adds: ColorName ...
user avatar
0 votes
0 answers
7 views

How do you remove header sitewide from mobile only?

I'm having trouble hiding my header on mobile devices. My wordpress theme does not have an option to hide it, so I was looking at the theme's header.php file if there was anything I could add to it. ...
user avatar
0 votes
1 answer
12 views

Assigning a category to a custom post type in Wordpress

I am working with custom posts to create a 'document' custom post type and then trying to assign the category during wp_insert_post, have tried using both post_category and tax_input to no success. I ...
user avatar
0 votes
0 answers
7 views

WordPress: Export/Import Yoast meta title & description to custom taxonomy

I want to export the Yoast meta title & description from a custom taxonomy with the WP All Export. Unfortunately there is no direct way with the plugin to do that. There is an extra WP All Export ...
user avatar
  • 145
0 votes
1 answer
17 views

End of blog roll or start of blog roll, _post_link = false / no link

Please help, how do you write this if next_post_link() = false / no link or end of blog roll : do this; else : return; endif;
user avatar
0 votes
0 answers
9 views

Modify WooCommerce used to get all orders in dashboard

The existing WooCommerce orders table in the wp-admin dashboard orders the results by the date the order was made, but I want to modify the query to order by date and also by the shipping method of ...
user avatar
  • 101
0 votes
1 answer
16 views

Show Featured Image Dimensions and size frontend with shortcode

I was wondering if I can show my featured image Dimensions (W x H in px) and the filesize in mb. In my Wordpress post with a shortcode. thank you in advance :)
user avatar
0 votes
1 answer
29 views

php redirect with custom user roles set and working but redirect not working for when users are logged in

I have created code to add custom user rules. It works. However when I try to tie in the code for redirecting an already logged in user based on one test role, then it doesn't work. What am I missing ...
user avatar
  • 13
0 votes
0 answers
11 views

Trying to create a Video News Page, that contains only the video and the title of the post that it was first uploaded to [closed]

I'm trying to create a new Page that contains only Videos, which are first uploaded inside a post that also contains some text and a title, which title I want to use to represent that particular Video....
user avatar
0 votes
1 answer
26 views

How to Add text value in Automatically in this conditions?

**how to input a text value in this conditions automatically , when user input text fields value ** **which condition do I apply ? ** code was added :
user avatar
  • 1
0 votes
1 answer
29 views

Let current user know pending posts counts using wp_query

I'm working on a query to let a logged-in user know if the user has more than 5 pending posts. Here's what I ended up with: // Start the query $query = new WP_Query( array( 'post_type' => '...
user avatar
  • 175
0 votes
0 answers
16 views

Page not visible in 'All pages' after being added through PHP

I'm adding some pages pragmatically as a subpage. This all works well on a test website in 1 locale. However, on the live website we have WPML with 2 locales. When adding them there, these pages DO ...
user avatar
  • 43
0 votes
0 answers
14 views

How to remove/hide collapse menu for user/subscriber?

I want to remove/hide the collapse menu item from the dashboard for user/subscriber role only. I don't want to remove it from the admin dashboard. I am the code below to remove it entirely which was ...
user avatar
0 votes
0 answers
24 views

Is there way to toggle the publish date display?

I am interested in changing our WP dashboard so that I can choose whether an individual Post will include the publish date or not. Is there a way to do it without a plug-in and insert code that maybe ...
user avatar
0 votes
0 answers
15 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
31 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
12 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
10 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
42 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
13 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
25 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
18 views

I can't start oauth xero start session in my plugin [closed]

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
25 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
19 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
77 views

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 [closed]

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

Upgrade theme to be compatible with php 8.1 [closed]

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
46 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,672
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
24 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
15 views

Error with automatically updating Wordpress in Plesk [closed]

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
10 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
100 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
15 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
48 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
29 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
27 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

1
2 3 4 5
200