Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. 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
0 answers
3 views

Closing Paragraph Tag Missing

The closing P tag is usually stripped out of the content whenever I use this code in my Functions.php file to insert an after a number of paragraphs. It leaves the unclosed. What could be wrong? // ...
0 votes
2 answers
1k views

How to disable register and reset the password from WordPress admin panel?

How to disable register and reset the password from WordPress admin panel? Please I want to do this by codes without using plugins.
0 votes
0 answers
19 views

Workaround for og:image unsupported webp image type, Yoast SEO?

My site Beta Fox uses Yoast SEO plugin to help deal with SEO common practices, however an issue has arisen. In beginning of last year WordPress didn't fully support webp image types, neither Yoast SEO....
0 votes
3 answers
845 views

How do I return an image from a script

I have googled but must not be using the correct terms. I am trying to add a script to my WordPress plugin that takes a url and returns a reformatted image. I know this is frowned upon as hotlinking....
0 votes
2 answers
941 views

Modifying child theme's header

I'm a noob. I have copied the header.php from the parent theme, I have added some snippets and things work. However, I would like to be able to add those same snippets either using a plugin or via ...
0 votes
0 answers
7 views

Comment Reply Link Reloading Page Instead of Moving Comment Form [duplicate]

In my comments.php, I loop through the comments like this: if (have_comments()) : ?> <ol class="post-comments"> <?php wp_list_comments(array( '...
0 votes
0 answers
10 views

How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes '&' to '#038;'?

I use a quick redirects plugin and it's changing my URLs after the fact and thereby breaking some of my links. I never want wordpress to change & to #038;. There is an unwanted solution to turn ...
0 votes
1 answer
18 views

How to properly replace the_content with the html in a php file?

I've built a plugin that needs to overwrite the content on a specific page. It works, but it places all content within the body, after my own html. Is there a way to fix that? add_filter('the_content'...
1 vote
2 answers
3k views

How to use thumbnail size of image if I'm only using src to get image

I have a custom field for an image, and using it this way: <?php $item_img = get_sub_field('image'); ?> <img src="<?php echo $item_img ?>" /> But I want to use the thumbnail ...
0 votes
0 answers
19 views

Hook on file upload

I need a hook or some way to detect when the window to select the file to upload is opened. I'm talking about the window that opens the browser to select the local files to upload. Context: On ...
0 votes
0 answers
6 views

How to change the author box selection on a post to a custom taxonomy

So instead of the author section pulling in 'Users', I need to change it so that the author box displays a selection of the terms from a custom taxonomy I have made. Is this possible to change?
0 votes
1 answer
58 views

Why is $wp->request empty in Wordpress 6.0?

Trying to obtain the page url with the following code prior to Wordpress 6.0 works, but after update to Wordpress 6.0, $wp->request is coming through as an empty string on all pages. I have Post ...
0 votes
2 answers
876 views

How do I output user_registered time in my correct timezone?

I am currently using Wordpress, and an element of user_registered returns the time of registration of the user. I have set the correct timezone, but don't know how to get the user_registered output to ...
0 votes
1 answer
17 views

WordPress navigation wont appear with wp_head

so im building a custom theme and ive got stuck on the navigation if i use wp_head(); it loads bootstrap and my custom style sheet but not the navigation if i use get_header(); it loads the navigation ...
0 votes
2 answers
2k views

Multiple do_shortcode($content) within one shortcode

TLDR; How can I run a shortcode with multiple shortcodes inside of it? I'm trying to run a shortcode with multiple shortcodes inside of it. I can successfully run a shortcode with one shortcode ...
0 votes
1 answer
797 views

Pagination reset problem

I need a fix for this web page. The page is attached if you wish to review the code. The pagination on each tab does not reset to 1 when the user has made a selection. This needs to reset when they ...
0 votes
1 answer
13 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', '...
1 vote
2 answers
1k views

Replace default og:image tag YOAST

I'm trying to replace the default image picked by yoast (featured image) with a custom with the relative og:image:width and og:image:height, but seems a mission impossible! I tryed with this: ...
0 votes
0 answers
15 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 ...
0 votes
1 answer
2k views

Fatal error: Uncaught Error: Class 'WP_Block_Styles_Registry'

I am having some issues determining the solution to this problem below. The website was sent to our team to fix. Turned on error reporting in wp-config.php: define('WP_DEBUG', true); ...
0 votes
1 answer
10k views

Website completely messes up when logging out

Alright so the website is completely perfect when I am logged into the WP-ADMIN page but if I log out of there, the website is completely messed up. All the formatting is broken and everything looks ...
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 ...
0 votes
0 answers
7 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 ...
0 votes
0 answers
12 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. ...
0 votes
1 answer
18 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 ...
1 vote
2 answers
1k views

How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field

I have searched high and low for a solution and couldn't find anything; hopefully someone here more skilled than myself can lend a hand. I have two testimonial videos (from a video custom post type) ...
0 votes
1 answer
585 views

Error `this set of changes has already been published`

A few days ago, having made some CSS changes in my additional css box, I got this error. Looks like something's gone wrong. Wait a few seconds and try again. I waited a few seconds and pressed ...
0 votes
0 answers
8 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 ...
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;
0 votes
2 answers
820 views

include javascript Multiple files in wordpress through script.js

i have script.js file for html to wordpress conversion. In html it works, but in wordpress it does not work. This file contains slider, menus etc, I enable to convert html to wordpress without this ...
0 votes
1 answer
2k views

PHP calling function within a class

I'm writing my own php class and I have multiple functions within the class. Something like this: class JSON_API_Hello_Controller { public function test_cat(){ global $json_api; ...
0 votes
0 answers
11 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 ...
5 votes
4 answers
5k views

How to hide get_theme_mod if field empty

I'm using: get_theme_mod to show various pieces of info from the theme customizer, in the following format: <a href=" <?php get_theme_mod( $name, $default ) ?> ">This is the link</a>...
0 votes
1 answer
600 views

Showing the authors username and bio on custom author.php

I have this code I'm using to create a custom author.php, which is working great to show that users posts and it's children etc: <?php get_header(); ?> <?php $curauth = (isset($_GET['...
0 votes
1 answer
1k views

Previewing/Updating some Pages causes "The requested URL was rejected" Error

The wordpress site is suddenly having a problem where on some (not all) of the pages, when you click preview page or update changes it gives an error message: "The requested URL was rejected. If you ...
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 :)
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' => '...
1 vote
1 answer
1k views

Replace shortcode in substring

I've created these two functions to toggle between the first paragraph of the content and then everything but the first paragraph so when the user selects 'More' it slides out the article smoothly ...
1 vote
2 answers
9k views

AJAX success response is not working but it's saving my changes

I'm a beginner in jQuery-Ajax so please bear with me. My Ajax response does not seem to load but my changes are being saved. but gives me this error on admin-ajax.php "call_user_func() expects ...
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 ...
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....
0 votes
1 answer
27 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 :
0 votes
2 answers
986 views

Showing Subcategory's Name and Link Instead of Parent Category's

Right now my code is displaying the category name and link. But if an article is in a subcategory, I want to display the subcategory's name and link instead of the parent category's name and link. For ...
1 vote
2 answers
2k views

You do not have sufficient permissions to access this page while making a plugin

You do not have sufficient permissions to access this page. This is the error i am facing while making my own plugin.Actually, i want to link to another page. Wordpress version is 3.8.1 I made a ...
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 ...
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 ...
0 votes
1 answer
591 views

Use AJAX to fetch Current Post Thumbnail for Wordpress when Uploaded throughMedia Uploader Frontend

i Use WordPress Media Uploader on Frontend to allow users to upload Thumbnail for there UGC site. I also show a Preview of the Image on Frontend. When a user clicks the button the Media Uploader opens ...
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 ...
0 votes
1 answer
1k views

Repeatable field within repeatable group of fields

Compounding on Saving metabox repeatable fields ... I've created a metabox with a series of fields that are repeatable. However, within those fields, I'd like to create another field named Choices ...
0 votes
1 answer
1k views

Path for contact form file

I have a php contact form that I use with all websites, so ideally I want to avoid using a plug in. The files used include: • contact.php - A file with php/html write up which displays the form ...

1
2 3 4 5
201