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
1 vote
1 answer
853 views

Restricting page by user role

I want to restrict certain pages according to user role for my wordpress site, so for example, when user with customer role wants to login to example.com/about page, they will be redirected to another ...
ByWorld's user avatar
  • 11
0 votes
0 answers
95 views

How to disable hover zoom on woocommerce. None of the common methods work

I have tried these codes in child functions and style files. Nothing works. add_action( 'wp', 'divikingdom_disable_wc_zoom', 99 ); function divikingdom_disable_wc_zoom() { remove_theme_support( '...
Raj Arjit's user avatar
  • 103
0 votes
0 answers
25 views

Pass a taxonomy term slug to the code in functions.php

I need code which would load more posts into a div via WP ajax on a taxonomy term page. My code loads posts if I only specify custom post type without taxonomy term but I need it to load posts only of ...
Brgerg30879's user avatar
0 votes
0 answers
51 views

Bulk Redirect WordPress Posts to Category based URL after Permalink Structure is Changed

function custom_category_redirect() { // Get the requested URL $requested_url = esc_url_raw(add_query_arg(array())); // Get the permalink structure $permalink_structure = ...
WordCent's user avatar
  • 1,867
-2 votes
1 answer
22 views

Custom function wordpress php

I need develop a function which will check the parameter in the url if the parameter is there need to write the functions inside. the function should check the example.com/login/?tokenrequest=xyz.url/...
mike's user avatar
  • 1
0 votes
0 answers
77 views

Embed dynamic php snippets with parameters in a blogpost

I have a setup where I embed some entities in my blogposts (products essentially) and then I have written a script and added to functions.php where I can all an API to get some metadata about each ...
ask's user avatar
  • 1
0 votes
0 answers
43 views

Import posts from a different database with the same old id

I am trying to retrieve data from an old custom programming to a new WordPress site, but I encountered a problem that I cannot retrieve the old id number. I need that to keep the site's archive, the ...
Kami's user avatar
  • 1
0 votes
0 answers
40 views

Load theme error? How do I fix this so people can see my website?

When people try to open my blog all they see is ?> ?> ?> /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells ...
Cornetta Camenga's user avatar
0 votes
0 answers
37 views

How to create (Add To Compare) in wordpress posts

I have a new custom type post called cars. And I'm going to create a page to compare cars. On the single page of each car, there is a table of technical specifications using the ACF plugin. Do you ...
och's user avatar
  • 39
0 votes
0 answers
26 views

Customize product card Up-sell on Woocomerce

I changed the product cards to also show the category and short description of the product but I can't show it in up-sell products. this is the code i used function category_single_product(){ $...
LesCa's user avatar
  • 21
1 vote
2 answers
73 views

Add function to single blog post pages only

I am wanting to add this code to single blog posts only after content. Right now it is showing up on every page after content. add_action( 'presscore_after_content', 'insert_cp_banner' ); function ...
nine19's user avatar
  • 11
0 votes
0 answers
32 views

woocommerce new order alert on a specific non admin page

I'm relatively new to WordPress but have basic understanding of how it works; I have a page where non admins can see woocommerce orders, I want to trigger a popup on this page when there is a new ...
petey's user avatar
  • 1
0 votes
1 answer
26 views

Strip and print only the numbers found in current's post excerpt (even if they are without space)

I have a working code for printing just the year (number) if found in the current post excerpt, but the problem arises when the number (a year) is followed by a Japanese character (example: '2023年', ...
vyperlook's user avatar
  • 177
0 votes
1 answer
479 views

How to get default variation ID (woocommerce)

I need to create an additional "Add to Cart" button on the product page. In a simple product there is no problem with this. It is more difficult in a product with variants. To create such a ...
patryk siuta's user avatar
0 votes
1 answer
76 views

wp_login_form display no styled form

I've created a custom template for a custom theme, I need to show the vue app that will manage the front end only to logged users. I've used this code inside my functions.php file and it's supposed ...
ICTDEV's user avatar
  • 123
0 votes
1 answer
29 views

wordpress media library description column

I have added a code to show a description column on media libray on wordpress, below is the code: function column_id($columns) { $columns['description'] = __('Description'); return $columns; } ...
sarika's user avatar
  • 1
0 votes
0 answers
49 views

Why nested REPLY not working in WP Comments?

<section class="postcomments"> <div class="comlist"> <h3><span>—</span>Comments<span class="comcount"><?php echo ...
WordCent's user avatar
  • 1,867
0 votes
0 answers
40 views

Disable RSS /feed/ endpoints on posts without disabling RSS overall

I recently found that Google Search Console has picked up the RSS links for the individual posts and pages on a client site and is attempting to index them. For example, https://example.com/this-is-...
kevinmcgillivray's user avatar
0 votes
1 answer
382 views

Add/Modify rel=canonical of all the pages of a wordpress website

Some background to the situation: We're currently running two exact wordpress websites at two different domains, xfilpak.com and xfilpak.ca. We want to make xfilpak.ca the canonical website. ...
Mohsen's user avatar
  • 1
0 votes
1 answer
55 views

Check if User Meta has Existing Value

Before running a command, I'm trying to check if a user already has a specific value (which is a Post ID) in a user meta key "saved_sessions". (This is a "favorites" type of system ...
Blake Miller's user avatar
1 vote
1 answer
29 views

Send An Email to Admin on User Profile Completion

I am trying to write a function that emails the site admin when a user profile reaches 100%. I found this piece of code that sends an admin email when a post is published: function send_admin_email($...
Ironlion's user avatar
  • 111
0 votes
0 answers
33 views

Syncing Nickname and "Display name publicly as" by default

I have a form that allows people to update their display_name. However, this doesn't work. I'm using Bricks Builder with Bricksforge but none of their own platforms seem to get the right answer. So ...
Pixel's user avatar
  • 1
0 votes
1 answer
27 views

How can I strip a single tag from an email post

I'm trying to send emails showing my post contents when I publish something on my site. However, my posts have videos so I'm trying to remove that from the emails that go out. Here is the current code ...
Jeremy's user avatar
  • 1
0 votes
2 answers
159 views

"acf/load_field" Critical error upon saving/updating WooCommerce products [closed]

I'm trying to prepopulate an ACF field called "upcoming_class_date" using "acf/load_field" but my code snippet returns a critical error upon saving/updating a product in ...
GrumpyCat000's user avatar
-1 votes
1 answer
103 views

I want change custom title in custom wordpress php page

H Guys, I have a page details.php in WordPress which is run like this [domain.com/product-details?id=706494861] And I want to show the product title as in the head. I have a listable WordPress theme. ...
SaMee Ch's user avatar
0 votes
0 answers
26 views

I need help with removing words or changing bulk slugs

Heres the best example. urls are in a domain.com/locations they say domain.com/locations/used-honda-cbr-goldwing-in-sarasota-fl I need them to say: domain.com/locations/used-honda-cbr-in-sarasota-fl ...
William's user avatar
0 votes
1 answer
37 views

How can I edit the wp_parse_auth_cookie function from the pluggable file in my functions?

I need to modify that function to decrypt the username that I have encrypted.
Miguel Angel Salas8's user avatar
0 votes
1 answer
27 views

<p> Tags being Inserted in html from plugin PHP not passing through the_content

I have an issue where some raw html is getting tags inserted where 'the_content' is not at play. I tried: remove_filter('the_content', 'wpautop'); remove_filter('the_excerpt', 'wpautop'); Already to ...
Mike Grotton's user avatar
0 votes
1 answer
142 views

CF7 Remove Comma from 'select' 'radio' and 'checkbox' outouts

I have a few 'select' 'radio' and 'checkbox' options on my CF7 form where the user can choose multiple options .. however on the output there is a comma between each item but I want to remove this ...
Tom Kidd's user avatar
0 votes
1 answer
20 views

Custom plugin doesn't show in admin menu - when code added, displays an empty page

my customer has this plugin: http://www.davmo.software/public/uverova-kalkulacka_v2.zip When installed, it doesn't have a link in the menu in the administration. I changed the $var variable in the '...
Petr Břeň's user avatar
0 votes
1 answer
39 views

Timeline from diferent wordpress api urls endpoint works, but diferent date

i created this snipped code to display in timeline wrap post title and post time, and it's work. But my problem is i see the las 10 posts but diferent date, the idea is display the 10 las recently ...
Hans Paul Pons's user avatar
0 votes
1 answer
39 views

Excluding a category from frontpage but not from WP_Query

I am successfully using this functions.php snippet to exclude category 3 from the WordPress homepage: function exclude_category_home( $query ) { if ( $query->is_front_page ) { $query->set( 'cat',...
joxyzan's user avatar
  • 13
0 votes
1 answer
70 views

How to get variable from other function inside class function using add_action for Ajax call

I want to access to variable "$sha256" from one function in other one that use both of them an add_action for Ajax call. I read that I must use a class function and add add_action with ...
imagIne's user avatar
  • 53
0 votes
1 answer
29 views

I want to allow certain file types on dokan upload files

Before we get started, I have tried alloweding "UPLOAD_UNFILTERED_FILES" thing on config.php and i have tried allow different mime type plugins, none of them worked I want to allow .rbxlx, ....
ItsBenny_'s user avatar
0 votes
1 answer
195 views

Log in and out using custom pages, no logout confirmation and redirects for logging in and out 2023

Good day, I'm having fun and games with having a custom elementor login page that i've designed myself that has a log in widget, having that redirect to a page with a different logged in menu and ...
indieben's user avatar
0 votes
1 answer
109 views

Add text below WooCommerce short description if metabox value is true

For WooCommerce I have a custom metabox that sets products to unavailable if ticked. The code below removes the add to cart button if a product is set to unavailable: // Remove add to cart button if ...
Dvaeer's user avatar
  • 629
0 votes
1 answer
191 views

WPDB query suddenly not working

I have a function that contains a wpdb query. It's supposed to get the image alt text, based on the url of the image. This is the function: // retrieves the attachment alt from the file URL function ...
Jillian Hoenig's user avatar
0 votes
1 answer
479 views

WooCommerce, change "Add to Cart" to "Link to Product", only for specific categories

I am using the code below to change the "Add to Cart" to "Read More" and link to the product page. My question is how to do that ONLY for specific product categories. add_filter( '...
geoplous's user avatar
  • 107
0 votes
1 answer
51 views

ACF number less than comparison not working

I have two ACF fields named as “price” and “reduced_price” now i have another field named as “price_filter” which should be filled with following conditions, If “price” is greater than “reduced_price”...
Shaharyar Afzal's user avatar
0 votes
2 answers
186 views

Is there a hook that I can use when a fatal error occurs?

Ideally I would like to log the user or page that triggers a fatal error so that I can follow up with that person or go directly to the page they were on for testing. My thought is that if there is an ...
Aristocles's user avatar
0 votes
0 answers
54 views

Prevent WP from escaping html on edit posts screen

In /wp-admin/includes/class-wp-posts-list-table there's a snippet of code that strips html from excerpts on the edit posts screen: echo '<span class="protected-post-excerpt">' . ...
lkl's user avatar
  • 107
0 votes
0 answers
135 views

Setcookie not setting cookies anywhere except admin

I want to set various cookies from the URL query string. I am checking for the GET values and then printing the desired values and then trying to set the value in the cookies. function on_page_load() {...
Varun's user avatar
  • 1
0 votes
0 answers
68 views

Block relation with specific domain in wordpress

I am facing an issue of redirect and the cause is a js file being load from 3rd party domain name. the script is added to almost 50% of my JavaScript that includes a Javascript file in header of my ...
Ali Abdullah Khan's user avatar
0 votes
1 answer
61 views

Disable Attachment Page Except for Category

I'm looking for a solution similar to here, except I want to keep attachment pages for attachments in a specific category. I tried adding the below function, but it's still redirecting all of them: ...
BlueHelmet's user avatar
0 votes
0 answers
60 views

sort by date in users

add a column with date, I bring the date with a shortcode from a plugin, I have the problem when trying to order it. how could i do function fc_new_modify_user_table( $column ) { $column['vencimiento']...
fakasmile1's user avatar
0 votes
0 answers
50 views

Exclude a category ID from the following function

I've used a query that will query if the post in a specific category, to show a list of subcategories it belongs to. The problem I'm having is I also want to exclude a specific subcategory from the ...
Emma's user avatar
  • 11
2 votes
1 answer
157 views

wp_script_add_data not working

We are trying to add "async" to our script using this code. However this is not added by wordpress. Not sure why it's not doing anything. function wp_mk_scripts() { if ( is_page(26202) )...
JoaMika's user avatar
  • 668
0 votes
0 answers
68 views

Is it possible to set the first image from a gallery as the product image, rather than the featured image?

I'm trying to replace the featured image of related products (woocommerce) with the first image from the product's gallery. Basically I don't want to affect the products in general (shop page). I want ...
Alex's user avatar
  • 1
0 votes
0 answers
34 views

Event Made Easy - Block registration to two or more events that have the same category

I really need help, I have tried several ways The rule is: The user can not register for another event that has the same category defined. In other words, the user has registered for event '1' which ...
Jessica Silva's user avatar
0 votes
0 answers
14 views

Customizer cuistom CSS Priority ordre Issue

function theme_customizer_styles() { wp_enqueue_style( 'theme-customizer-css', get_template_directory_uri() . '/css/theme-customizer.css' ); } add_action( 'customize_controls_print_styles', '...
WordCent's user avatar
  • 1,867