Questions tagged [functions]
A function is a sequence of program instructions that perform a specific task. It is packaged as a unit that can be used wherever the according task should be performed.
5,759 questions
3
votes
2
answers
150
views
Show exact search results and include post comments?
I'm resurrecting two older Q&As in this question to ask: is it possible to show exact search results which includes comments? Without any plugins?
This function is from an older Q&A Incude ...
1
vote
0
answers
66
views
Cron task for creating a file of bookings.ics
I need to setup a cron task in order to generate a list of bookings.ics from my Bookings Calendar plugin. My function which is located inside my functions.php is this one. It is processing my bookings ...
0
votes
1
answer
76
views
Is there any downside to making a theme fully pluggable? [closed]
if ( !function_exists( 'my_function' ) ) {
// do function
}
I'm not sure why, but it never occurred to me before to make a theme fully pluggable so that it's easier for people to customize with a ...
0
votes
1
answer
76
views
How to return all data from a grouped metabox(cmb2)
I have a grouped metaxbox values from cmb2, when I return it to display output, it shows only one of them, but actually it has four value stored. How could I display all grouped metabox value?
Here is ...
0
votes
1
answer
53
views
Executing .py scripts from functions.php
I would like to run and store the value returned from a python script, in response to certain admin actions.
I've tried a bunch of suggested solutions but the only method that has worked for me is:
$...
0
votes
1
answer
53
views
Remove and strip html tag values
I have imported some blog posts from an external site and there were unnecessary html tags and values I wanted to get rid of like the sizes and srcset including their values for all blog posts. It ...
0
votes
0
answers
30
views
Why Logo Size is Large?
I set the logo size to 200px 200px but on the site logo is bigger. It is set to image size 626px 626px
function theme_support() {
$defaults = array(
'height' => 200,
...
0
votes
1
answer
91
views
set a Gravity Forms uploaded image as a user’s avatar
I’m using Gravity Forms to allow users to register on my WordPress site. I’ve added a file upload field (ID: 6) for users to upload their avatar. I want to set this uploaded image as the user’s ...
0
votes
0
answers
30
views
Sharing website link shows author name but only on GROUPME
When I share my website link on groupme it shows my author name. I have changed my nickname to the website name and it has not changed. I have downloaded plugins to hide the metadata and so on. I also ...
0
votes
1
answer
35
views
Re-use date format on different template
I am using the wp-hotelier plugin. The /booking page displays $checkin and $checkout dates/times in a user-friendly format (e.g 30 January 2025 (12:00 - 21:00) / 31 January 2025 (08:00 - 13:00))... ...
1
vote
1
answer
92
views
Rewrite standard $errors messages output via function.php
For example:
ERROR: Invalid email address. Lost your password?
I want to catch it and show my own message instead.
I can edit user.php in WordPress but I don't want to touch base (core) WP files.
3
votes
1
answer
197
views
Developing a "fallback" for empty wp_query results based on post dates
I'm trying to set up a "fall back" query for wp_query. I want to get the first post that is one year old, but if that doesn't exist, get the first post that is one year and one day old. And, ...
1
vote
0
answers
72
views
Gravity forms adding classes to specific form elements [closed]
I have read thru Gravity Forms docs, forum posts, et al and cannot find a way to target the Checkbox container element, and checkbox wrapper DIVs to add specific classes to them.
My goal is to ...
0
votes
1
answer
45
views
No src and sizes attributes present on Wordpress thumbnail images; the smallest image size is loaded irregardless of viewport size
I have set up custom thumbnail sizes in my functions.php, as follows:
function df_theme_support() {
add_theme_support('post-thumbnails');
//Custom image sizes
add_image_size('small-thumbnail', ...
1
vote
0
answers
81
views
Post Navigation Elementor
I'm using Elementor and ACF on a website and have a custom post type for events. In elementor I have the posts on the archive page set to order by the ACF start date field. When the user clicks the ...
0
votes
0
answers
26
views
Trying to change the default page break numbering format
You provided an answer on the below post, I wanted to ask if this should work on Wordpress posts or pages, Im trying to do something similar for posts but I added your code to functions.php and it ...
0
votes
1
answer
33
views
WP backend, Show only own comments (give to users who wrote/published/assigned) posts
I want to limit this in the WP admin:
Show only own comments (given to users who wrote/published/assigned)
posts (Admins excluded).
also the filters numbers will be assigned to user posts not as im ...
3
votes
3
answers
146
views
Is it possible to automatically set the publication time to 8am on new posts?
This might be kind of funky to pull off, but does anyone have any ideas on how I could automatically set the time to 8am on any newly created post drafts? In both the Classic Editor and the Block ...
0
votes
1
answer
55
views
How to sort a non-meta field in the User Admin Panel?
I'm stuck, and haven't been able to find an answer after much searching.
I need to modify the User Admin Panel showing the list of users and the number of posts. I have custom posts (type = 'articles')...
0
votes
1
answer
42
views
Function extension
I have the following code:
function auto_link_post_titles( $content, $post_id, $field ) {
$excluded_ids = array(); // Put the IDs of the pages you want to exclude here
$excluded_field_names = ...
0
votes
1
answer
50
views
How to build an expiring function in Wordpress?
I need a Data Layer in my WordPress header.php. It's already running by author like this:
<?php $author_id = get_post_field('post_author', get_queried_object_id()); if (get_the_author_meta('...
1
vote
1
answer
47
views
Exclude function for custom pages, exclude custom ACF fields
I have the following code:
function auto_link_post_titles( $content ) {
// Sets the post type(s) we'll retrieve.
$desired_post_types = array( 'my_post_type', 'my_other_post_type' );
// ...
0
votes
1
answer
78
views
Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
I am getting the following error: Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. I have gone through plenty of other similar questions ...
0
votes
1
answer
110
views
Function to filter numbers from string
I'm looking to filter numbers from a string, and make them bigger in one case, and hide them in the other. The best way, as I understood, would be to use a custom function via functions.php and ...
0
votes
1
answer
55
views
How to access a function declared in child theme's functions file in a plugin file?
I have a function declared in my child theme's functions.php file as seen below:
function test_fn(){
error_log("Test fn");
}
When I am calling this function in a plugin file, I am getting ...