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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
39 views

How do I get a function to work in single.php

I have a code. add_action( 'init', 'njengah_change_post_date_programmatically'); function njengah_change_post_date_programmatically(){ $time = current_time('mysql'); wp_update_post( array ( ...
Guruh's user avatar
  • 3
0 votes
1 answer
72 views

wp_head not injecting css

I'm trying to inject a style.css script into my front-page.php. None of the styles load. In the tutorials, when you inspect page source, all the CSS should be there, but it simply shows the wp_head() ...
Shawn Esquivel's user avatar
0 votes
0 answers
44 views

How to add height and width dimensions automatically to archive descriptions

I have this code which adds height and width data for images in posts and pages: function add_img_size($content){ $pattern = '/<img [^>]*?src="(https?:\/\/[^"]+?)"[^>]*?>/...
Tom Tolkien's user avatar
0 votes
0 answers
119 views

Call wordpress function through functions.php when pressing menu

I have created a menu through wordpress admin menu creation but I'd like to call wp_cache_flush() when I press every menu item... is there any hook I can call through functions.php so I can execute ...
Luigino's user avatar
  • 103
0 votes
1 answer
158 views

Gravity Forms and Gravity View Permissions

I have a pretty direct question. I am trying to figure out how to programmatically prevent users from being able to view other users' form submissions. Currently, using Gravity View, any logged in ...
MrChoop's user avatar
1 vote
0 answers
125 views

How to get meta box labels?

I know how to add a meta box, and I know how to retrieve meta box values. That's not what I need; I just want to clarify that first. What I need is to get meta box labels by id. I am adding links to ...
Aristocles's user avatar
0 votes
1 answer
224 views

Working function() doesn't execute when triggered by WP CRON

I've built the following before and have referenced my own code to see if I missed anything and from what I can tell I have not. I have a WP CRON scheduled and it executes as the scheduled intervals. ...
Tony Djukic's user avatar
  • 2,044
-1 votes
1 answer
31 views

Make plugin admin page visible to other roles

I have created a plugin that I want users with the role of 'Editor' to be able to see and use in their admin panel.Currently, only administrators can see and use this plugin. I believe it has ...
Pelle Nilsen's user avatar
-1 votes
1 answer
265 views

Option value not getting updated until page refresh in WordPress

I am building my WordPress plugin. There, at first I am using a checkbox, and then updating the value from the checkbox (yes or no) in the Database. Then, from later on I am fetching the value form ...
Rajin Sharwar's user avatar
0 votes
0 answers
77 views

Update post meta with wp cron

I am trying to create a function (which I will trigger through the WP Cron) but no values are passed and the database values remain NULL. Could anyone point me in the right direction of where I'm ...
Rein's user avatar
  • 1
0 votes
1 answer
28 views

Best way to delete/don't load a .php file?

In my theme files, I have a footer.php file that I can delete with no repercussions because I am using something else. What is the best way to delete/don't load that .php file? Until now I'm deleting ...
Phil's user avatar
  • 1
0 votes
0 answers
13 views

Selected dropdown option is not getting saved in the DB [duplicate]

I am building a function within my plugin where I have the list of available pages being displayed. What I want is for whenever a user selects a page from the dropdown, it should save the slug of the ...
Rajin Sharwar's user avatar
-1 votes
1 answer
38 views

How to add different menu items on different menus?

This may sound weird, but I need to add different menu items to two specific menu types. When I mean different menu items, I mean, the items I set to main (header) menu are only for that menu and the ...
AtomX's user avatar
  • 109
0 votes
1 answer
73 views

How can I save the selected page in the dropdown after anyone clicks on Save Changes?

I am trying to build a function for my plugin. Now, I am displaying the dropdown of all available pages. What I want is for when anyone chooses a page from there and clicks on Save Changes, the page ...
Rajin Sharwar's user avatar
1 vote
1 answer
960 views

Problem with lists and "allowed_block_types" in functions.php (since WP 6.1.1)

I often use the "allowed_block_types_all" function in my functions.php to disable unnecessary blocks. Since WP version 6.1.1 (or 6.1) there is a problem that the list block in Gutenberg ...
DomHu13's user avatar
  • 13
1 vote
1 answer
300 views

Text before price on WooCom

I want to add text before the price on the WooCommerce product catalogue only, which I have working using this code in functions.php: // Add text before price function bd_rrp_price_html( $price, $...
jpopuk's user avatar
  • 13
0 votes
0 answers
2k views

a problem in class in class-wp-hook.php

I get the problem this morning Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wp_ob_end_flush_all' not found or invalid function name in /home/legotechnic/...
walis's user avatar
  • 1
0 votes
1 answer
67 views

PHP Creating a formula from mysql db values and db stored math operator

I am trying to use variables stored in a DB and math operator (e.g. * + - /) to allow users to build formulas e.g. (Night Shift Hours*Night Shift Time Rate)*0.2 The formula string is build from ...
GURU mcewan.marriott's user avatar
0 votes
0 answers
380 views

Contact form with dynamic dropdown and filter

A client wants to create a contact form for a moto parts store that allows users to choose their moto make-model-year. They want this information to provide better assistance after the contact. They ...
franjapaez's user avatar
0 votes
0 answers
25 views

Critical Error customiser

Ive successfully added all posts (of a custom post type) to my wordpress menu using this method:Here Everything is working great. Unfortunately when I view the customiser, I get the "critical ...
essential grower's user avatar
-1 votes
1 answer
21 views

Insert image between X number of posts but on specific paginated pages?

I'm inserting an image in-between every 5th post using the code below but obviously it shows up on every paginated page. Is there a "pagination" function available to show the image every ...
Nate M.'s user avatar
  • 67
0 votes
1 answer
48 views

How to fix enqueue_styles error for a twenty-seventeen childtheme

I have searched your site but cannot find and fix this error I get: Notice: Function wp_enqueue_style was called <strong>incorrectly</strong>. Scripts and styles should not be registered ...
Prink1978's user avatar
0 votes
0 answers
48 views

WP Custom tables query

I returned to PHP / MySQL development after a long break, and I am working on a project that requires some customization. First, I added a credentials file; then I am referencing that file in my test ...
Sam's user avatar
  • 1
0 votes
0 answers
54 views

get_term_by() returning null on plugin

I'm creating a woocommerce product category using Guzzle on my plugin, that i was able to do, but then when i try to get the terms of this category, using the function get_term_by(), always return ...
Gabriel Rodrigues's user avatar
1 vote
1 answer
328 views

How to get postId from the argument $block when register_block_type()?

I'm trying to register custom block type in the file functions.php of my block theme: function render_custom_block($attributes, $content, $block) { return $block->available_context['postId']; } ...
stckvrw's user avatar
  • 285
0 votes
0 answers
366 views

Warning: filemtime(): stat failed for wp_

Currently getting this warning in php. Warning: filemtime(): stat failed for https://madeupurl.com/wp-content/themes/madeup/assets/js/scripts.js in /var/www/wp-content/themes/madeup/functions.php on ...
HomeWell Web's user avatar
0 votes
1 answer
17 views

Removing all Category pages with one exception

I am using this code to remove all category pages, however I wish to retain a certain category with ID number 20. How may I do this please? // Remove category archives add_action('template_redirect', '...
JoaMika's user avatar
  • 668
1 vote
0 answers
26 views

WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?

You know WordPress is adding pagination for all pages not only for posts page/blog page. For example www.mysite.com, I'm getting URLs like www.mysite.com/page/15, etc. Here, www.mysite.com has a ...
Murali Krishna P's user avatar
0 votes
0 answers
60 views

Replace the image of a product with its video in the shop page

I am trying to replace the image of the products with its video in the shop page. I tried this one add_action( 'init', 'get_product_video_url' ); function get_product_video_url() { $product_ids = ...
dev-one's user avatar
0 votes
1 answer
285 views

Too few arguments to function woocommerce_update_product_acf_save_post()

I have an action in my functions.php to inform subscribers of an product update. I have a working function that accepts 2 arguments ($product_id and $product). However when I press update on a product ...
J. Minnebo's user avatar
0 votes
0 answers
55 views

Different ads on every website on multisite environment

I am using following code to insert ad in article, after 8th paragraph, through functions.php file: add_filter( 'the_content', 'prefix_insert_post_ads' ); function prefix_insert_post_ads( $content )...
ZeusDev's user avatar
0 votes
2 answers
43 views

A better way to write this php function

I have a function that has a few and/or operators in it. I'm sure there is a better way to write this but can't seem to figure it out. I thought I could use arrays but ran into an issue with having ...
protagonist's user avatar
0 votes
0 answers
146 views

Get full slug for a Wordpress Post

I am using this code to get the URL of a post which is subsequently used as input on a form field. global $post;$post_slug = $post->post_name;$post_slug = urlencode($post_slug); However, this ...
JoaMika's user avatar
  • 668
0 votes
1 answer
64 views

Custom Post-Rename Function Does Not Function in WordPress 6.x

I have the following function in functions.php in a child theme: <?php add_filter( 'wp_insert_post_data' , 'modify_post_title' , '99', 1 ); // Grabs the inserted post data so you can modify it. ...
Zyniker's user avatar
  • 105
1 vote
0 answers
33 views

Assign new post author IF another user in custom field on post transition

I have a post that is being made on behalf of someone else - so a team member adds the post for the author using a frontend form, but when the post status changes to publish, I want the selected user ...
Yasmine Finbow's user avatar
1 vote
0 answers
31 views

Sorting Problem

I tried to change the Functions.php to this code add_filter( 'terms_clauses', 'wpse247680_terms_clauses', 10, 3 ); function wpse247680_terms_clauses( $pieces, $taxonomies, $args ) { // ...
Miguel Andrade's user avatar
0 votes
0 answers
252 views

WordPress Importer Call to undefined function set_time_limit()

I am trying to import my media library via the wordpress importer, but I keep running into this error, which seemingly lacks an explanation: root@test:~# grep -R "max_execution_time" /etc/...
mjones's user avatar
  • 153
0 votes
2 answers
31 views

Display terms on product page with shotrcode

I need to add some shotrcodes for many taxonomies and I would like to display the value terms on a product page of woocommerce. I tried with this but doesn't work, in this case the taxonomy name is &...
Marco Fabris's user avatar
1 vote
0 answers
13 views

Create and publish a new post every Monday, listing the post titles and links to the posts published during the previous week

Newbie to Wordpress and PHP! Every Monday, my task is to create one post (let's call it summary) in a custom post-type called "news". In summary, the "contents" field will be a ...
satoshi's user avatar
  • 11
0 votes
0 answers
52 views

Stop breadcrumb function retrieving custom post type template name

I have created a function that pulls in the breadcrumb of a page/post. However, I am having a problem where it appears to pull in the custom post-type template name rather than the actual name of the ...
Jordan Kellet's user avatar
0 votes
1 answer
612 views

Alternative to php echo within code

I am writing within the functions.php file, and am trying to display HTML code, along with back-end php code. My problem is using the echo statement. It is rather difficult to use the echo function, ...
John Lyons's user avatar
0 votes
1 answer
54 views

Create Wordpress category dynamically

I have more than 15 Category , And i have a custom taxonomy "classroom", Is there any way to Create those categories automatically when i activate plugin?
Hello world's user avatar
0 votes
1 answer
94 views

Slug not being updated using wp_insert_post

I am using this code to change the slug of a URL page every minute. However, nothing happens. I would presume the problem lies with post_name ? function wpse402903_schedule_event() { add_action( '...
JoaMika's user avatar
  • 668
0 votes
1 answer
58 views

Show Next/Previous without Link

I have a question. Currently I have <?php next_post_link('%link', 'Next Post'); ?> and <?php previous_post_link('%link', 'Previous Post'); ?>. Both return Next and Previous with a link. I ...
Jornes's user avatar
  • 743
1 vote
1 answer
127 views

How do I change the Go To Categories link in the term_updated_messages

I have a custom taxonomy titled "shows". When a show gets updated it displays a message to the user followed by a link. I have already changed the message by using add_filter('...
Jason's user avatar
  • 205
0 votes
1 answer
625 views

Add multiple HTML attributes to an Elementor button

I want to add multiple HTML attributes to a button which is present across all blog posts on my website. The buttons all have links in them, to which I want to add like 3-4 'rel' attribute values. I ...
Kai's user avatar
  • 3
0 votes
1 answer
146 views

image_size with respect to aspect ratios

I have image assets that I load externally and insert programmatically. There are 3 different asset classes: landscape, portrait, and 1:1 The default image_sizes are creating a lot of clutter that's ...
Fluxian's user avatar
  • 130
0 votes
1 answer
97 views

how to display custom taxonomies in front page

I have created custom post type Music which have two taxonomies Artist and Album. Now I want to display an albums table which contain all albums and display it in a page, and same for artists. Can ...
Jane's user avatar
  • 1
0 votes
1 answer
988 views

Remove default Image Sizes

I'm trying to remove the default image sizes that are created given a specific image size threshold. Listed using this: get_intermediate_image_sizes() // thumbnail [1] => medium [2] => ...
Fluxian's user avatar
  • 130
0 votes
1 answer
26 views

WooCommerce: write featured image dimensions to custom fields in product'

It's all in the title. I'm somewhat handy with php, less so with WP hooks and subroutines. When I originally select (or later change) a featured image for a product, I want the pixel dimensions of the ...
Joe Foe's user avatar

1
3 4
5
6 7
115