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

How to Add a cutsom slug to my custom author role

My new custom user role that I just created has this default slug like demo.com/author/peter , I want to change the it for a particular custom role to demo.com/editor/peter without using a plugin, the ...
user avatar
  • 1
0 votes
1 answer
34 views

Detect Ajax call inside pre_get_posts function

In the front end, I have a custom post type archive page with an AJAX Load More button. The loop of the archive page is ordered by date and ASC. I use the same args for the AJAX loop inside a ...
user avatar
0 votes
1 answer
15 views

Execute function only for specific user roles

I'm referencing the below solution (which came from here Force Password Complexity) to enforce a certain level of password security. It works as expected, but it is running for ALL user roles. I do ...
user avatar
0 votes
1 answer
49 views

Call to undefined function is_home() or any conditional tags

Currently I am coding in my own custom plugin. For some reason I can't use conditional tags inside my function. For example function check_home() { if(is_home()) { $my_val=1; } else { ...
user avatar
0 votes
0 answers
38 views

php dynamic content inside shortcode

I've got custom field added to my woocommerce page in functions.php. I want to add on a product list page an shortcode with dynamic content from that custom field - it will be url. I've added ...
user avatar
  • 1
0 votes
1 answer
36 views

Override a function defined in wp-includes/comment-template.php

I need to override the function get_cancel_comment_reply_link or cancel_comment_reply_link that are defined in wp-includes/comment-template.php These functions are not listed in pluggable.php. How ...
user avatar
  • 77
0 votes
0 answers
16 views

Show metadata in users.php - wordpress

is there any way to show metadata in the list of all registered users "users.php"
user avatar
  • 3
0 votes
0 answers
22 views

Render page with specific id from functions.php

How can I render a page from functions.php with a specific page id? I tried something like this: $template = locate_template('page.php'); if ($template) { set_query_var('page', get_post_meta( 200 )...
user avatar
0 votes
1 answer
42 views

Add version # to wp_register_style function

How do I add a version number correctly? I have checked wordpress codex but their wp register style function looks different than mine and I don't want to break anything. Here is mine ...
user avatar
0 votes
1 answer
25 views

Why should I use get_template_directory() when include files?

When I include files in wordpress I noticed that include works fine without get_template_directory(). Include even works fine without parenteses. include( get_template_directory() . '/includes/front/...
user avatar
0 votes
0 answers
14 views

Display Child Pages if no child Exists Display Siblings

I am using this code to display child pages, but if there are no child pages I need to display siblings and have not been able to get it sorted. function childpages_shortcode_callback( $atts ) { $...
user avatar
0 votes
0 answers
137 views

How to remove font awesome from loading in wp theme

Question: How to remove font awesome from loading in theme and replace social icons with images? Theme Hueman - WP Multisite install What I did: In the functions.php of a child theme from Hueman Theme,...
user avatar
  • 23
0 votes
1 answer
175 views

How to send a php var to jQuery Ajax call with two different file

I need to send a private e-mail address from a php file (page.php) to an Ajax Call in an other jquery file (sender.js). This e-mail address must be invisible to user/or website until the user get an ...
user avatar
0 votes
1 answer
25 views

Unable to return values from function

The function below is intended to return a list of the WordPress submenu pages. function get_admin_menus() { global $submenu, $menu, $pagenow; if ( current_user_can('manage_options') ) { ...
user avatar
  • 11
0 votes
1 answer
30 views

Wp-query Order By problem

I'm trying to sort a query according to the order they write it in but it takes an order by ID. The variable $idpaginas prints: 20659,20626,20585,20616,18464,19748,19991,18520,20588,21268,18753,20556,...
user avatar
0 votes
0 answers
16 views

How to show ACF value under post/page title in wp-admin

On the below thread I see a solution that is exactly what I want, but using Advanced Custom Field "How to show custom field's value under post/page title in wp-admin" So what changes I must ...
user avatar
0 votes
0 answers
35 views

add_rewrite_rule to load different page, without changing URL in browser

I need a function(s) where I load to 1 specific page (index.php?p=49) whenever a URL is written with an all numeric slug/end. However, the written URL has to remain the same in the browser as it ...
user avatar
  • 1
0 votes
1 answer
51 views

How to display an image before title text in menu items

I am using Advanced Custom Fields to add images to individual menu items. These images are being appended to the $item->title with the following code: function wp3456789_wp_nav_menu_objects( $items,...
user avatar
1 vote
1 answer
120 views

Wp_query function to search from product_title 'OR' product tags name

I am looking to show search results from either product title or product tag name. I have implemented the product title search through the below code, but I need to add tag name search also into it. ...
user avatar
0 votes
0 answers
71 views

How to fix Function create_function() is deprecated in / themes

Apologies as the topic has been asked several times, but as a newbie I'd like to ask a specific help on rewriting the code below. The problem raised when I switched an old site to PHP 7.3 and the ...
user avatar
  • 1
1 vote
0 answers
36 views

Using a function to change favorites listing

Sorry - total newbie here with Wordpress development. I have the following plugin installed https://favoriteposts.com/ and it allows you to change the default output of the users favorites by using ...
user avatar
0 votes
0 answers
19 views

how to show comments only author which send own posts in wordpress

I am trying to make things work like where author can see only them post comment in admin comment section . While admin should have all permission. I am having author's post comments in comment ...
user avatar
0 votes
0 answers
22 views

Providin exception to Wordpress wp_nav_menu Custom CSS Classes

I use below code to remove unusued menu classes. function clear_nav_menu_item_class($var) { return is_array($var) ? array_intersect($var, array('menu-item-has-children')) : ''; } add_filter( '...
user avatar
0 votes
0 answers
16 views

Block all plug-ins from initiating redirection upon activation?

Some Background Info It seems to have become increasingly common for plug-in developers to take the liberty of redirecting wp-admin to the respective plug-in's settings page upon activation of the ...
user avatar
  • 358
0 votes
0 answers
8 views

implement custom roles in custom plugin

i am developing an Wordpress plugin which actually works quitte good ;-) But i have a requirement to implement user roles. So i am reading stuff about custom capabilities in wordpress. There is so ...
user avatar
0 votes
1 answer
69 views

Display a list of random terms from custom taxonomy with shortcode

I try to output a list of terms from my custom taxonomy. I am almost sure I was using this code snippet before, but somehow WP throws errors: shuffle() expects parameter 1 to be array array_slice() ...
user avatar
0 votes
0 answers
41 views

Change wordpress' database data using ajax - how to get current user id?

I want to update a wordpress' database using ajax. I've created php file and included both wp-includes/user.php' wp-includes/pluggable.php' and when I call $current_user = wp_get_current_user(); $...
user avatar
  • 1
0 votes
0 answers
14 views

Woocommerce My acount page

I writen template for woocommerce. I have 2 languages polish and englisch. I would like to set the link for language polish "localhost/domain/moje-konto/" and for language englisch "...
user avatar
0 votes
0 answers
27 views

Woocommerce - Exclude variation attribute on specific variation

I want to hide some attributes on specific variations. I have the following attributes: Printing Position , Printing Technique , Print size, Colors. You can see here https://ibb.co/qjV3Z75 that i have ...
user avatar
  • 57
0 votes
0 answers
22 views

How do I change where "You must be logged in to comment" directs users?

I've seen a few answers to this question on this site, but none are current and none are very well explained. Is there any definitive answer to this question? It seems like a lot of folks want to know!...
user avatar
0 votes
0 answers
20 views

Custom route and extract data from slashes and parameter

some external website is going to send a specific data into a WordPress site and need to extract and process it. The data is coming trough URL (between slashes and as parameter): domain.com/login_sso/...
user avatar
0 votes
1 answer
20 views

Edit the_category (); for a hierarchical display

For my wp theme I want to use the categories as tags on my posts. Example: The problem is that the category in red must always be the parent and in gold the child. Except that returns the categories ...
user avatar
0 votes
0 answers
34 views

Gravity Forms - Custom Merge Tag Convert date_created to Local/WordPress Time?

I create a number of custom merge tags on my forms, one of which is "Date Submitted" which references the Gravity Form 'date_created' property as seen here https://docs.gravityforms.com/...
user avatar
0 votes
1 answer
61 views

Wordpress Custom Hook with Class method

The code described below works normally outside of wordpress, but in wordpress I get "warning expects parameter 1 to be valid callback function mycars ($ mycarsclass) not found". If I remove ...
user avatar
  • 1
0 votes
0 answers
10 views

How to add custom metakey to shop_order page's searching function?

My project is a eShop with POS system,The POS is powered by YITH POS. Work with YITH POS its will generate a metakey in wp_postmeta call '_yith_pos_store' to linking the store name. For make it easier ...
user avatar
  • 1
0 votes
0 answers
54 views

Dynamically populate parameter in Gravity Forms using PHP

I have a global form I want to implement on our Product Catalogue, the product catalogue is written entirely in php (not a plugin) and it has a category and product filter. When you click on a product ...
user avatar
  • 1
0 votes
0 answers
15 views

Create category for each user

How do you create a category for each user that registers? I tried to add this in my functions.php function fun( $user_id ) { $user = get_userdata( $user_id ); wp_insert_term( 'My New ...
user avatar
0 votes
1 answer
23 views

How to get current cart values using WC_Shortcodes?

I am trying to get current cart items from my own plugin using WC_Shortcodes::cart(); this will return cart details in html format. WC()->cart->get_cart(); code not working. i need only cart ...
user avatar
  • 3
0 votes
1 answer
54 views

Exclude specific post from query

In the category post archive, I want to display the last 10 posts and 1 featured post (featured post only on the first page). I can choose a featured post that will be displayed first (user can select ...
user avatar
0 votes
0 answers
16 views

How do I add a function to parent theme

I am looking for advice on how to add a function / hook to a parent theme. A colleague has installed a WordPress theme, but not child theme as I have tried adding a function to the child theme but ...
user avatar
0 votes
1 answer
30 views

Can't log in to WordPress wp-admin after adding code to functions.php

I am adding the following code to the end of my functions.php file to populate a taxonomy based on a Custom post's post-title. The problem is that when I add the code I get the following error trying ...
user avatar
  • 1
0 votes
1 answer
28 views

Create Wordpress User in backend, and automatically create a new post in Custom Post Type with user uame as the Title in the post

We are developing a golf tour itinerary system for our clients, and we only want client with unique booking reference 221234 to see their tour itinerary, which is on a CPT titled 221234. Is there a ...
user avatar
1 vote
1 answer
20 views

Sorting table function default

Trying to get this table to sort by default by "publish_date" Where can I add it? $transaction_params = array( 'posts_per_page' => $page_size, ...
user avatar
0 votes
0 answers
21 views

wp_set_object_term via js btn frontend

Hi I just copied some code to change a post custom field term by clicking on the btn with #projects-pay-btn id and work with it on frontend as end user, but it does not working. when the user push the ...
user avatar
0 votes
1 answer
32 views

Is there a function for setting a password to a post?

Like set_post_password( $post_id, $password ) or similar? I can't find anything. Do I have to make use of $wpdb?
user avatar
0 votes
0 answers
56 views

Error using wordpress functions inside a plugin class

Hy! In my plugin activation class i used wordpress functions (get_user_meta, update_user_meta) <?php /* Plugin Name: Integração Pagarme Dokan Description: Integrar os plugins pagarme para ...
user avatar
0 votes
0 answers
22 views

Are there any drawbacks on opening a session_start in functions.php and header.php?

Are there any drawbacks on opening a session_start in functions.php and header.php? Especially from a speed / loading speed/time and resource perspective? Anybody? Happy to learn about this!
user avatar
  • 287
0 votes
0 answers
188 views

Store ajax data in PHP variable

I made an ajax call to get ID from the dropdown menu, I want to get this data store in variable PHP to make something ajaxcalls.js $(".developer_select").on("change",function(...
user avatar
0 votes
0 answers
24 views

Advanced method to control cache of enqueued style/script

I have a WordPress website with medium-level traffic, ~10,000 unique visitors a day. Arround 30% of my daily visitors are recurrent. I constantly make some UI improvements: colors, font-size, ...
user avatar
0 votes
1 answer
23 views

How can I show a specific page to admins only?

I have a cart and shop page that I would only like to be accessed by admins. For the purposes of adding products and then using a share cart button to send to the consumer so that they may complete ...
user avatar