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
0answers
12 views

Extending a Plugin, Having Some Trouble with an Array & Foreach

At the core, I feel like I'm missing something very simple. I have a variable set using another plugin's function. This variable needs to set data inside of an array, like so: $...
0
votes
0answers
15 views

Is there a built-in function to generate multiple paragraph tags based on a string with new line separators?

Consider the following code <?php // The new line separated string $section_string = <<<EOL Sentence A1. Sentence A2. Sentence A3. Sentence B1. Sentence B2. Sentence B3. Sentence C1. ...
0
votes
0answers
21 views

Custom meta box is not displaying value showing tag as empty

I have a created a custom meta box plugin and a function in the functions.php file to output the value on the page. The meta box seems to be working, however the input text is not being displayed on ...
0
votes
1answer
28 views

Why wp_ajax hooks doesn't work?

I need to execute the Php function from my Ajax form with the POST method. Is there another way instead of ajax hooks? Hooks doesn't execute. Always returning 0. What's wrong? Here's my ajax.js '...
0
votes
0answers
19 views

creating html reusable blocks via shortcodes

I'm using a really simple and fast theme in order to reach a good speed score, so i'm not using any visual composer, but writing my own sections in pages via html i have some sections and cta that i'...
-1
votes
1answer
15 views

Suppress errors when using global function

I'm using the NinjaForms plugin which defines a Ninja_Forms() global function. Although I can call it without problem, I still get a warning/error Undefined function 'Ninja_Forms'. If this were a ...
0
votes
0answers
17 views

Edit plugin function with a hook

I've just spent 2 days on trying to pass/change an argument in a plugin's function but had no luck so far. Would anyone, please, show me the correct way or solution how to do that? I need to be able ...
-1
votes
0answers
6 views

YITH Product add on does not show with WooCommerce Multi Currency Premium

I need Help… I sell tickets to the event with different types of add ons in Euro but at the checkout page the prices have to be converted to MDL currency because of the legislation, so the whole way ...
0
votes
3answers
29 views

Trying to get the path to my child-theme via my functions.php

I am calling a CSS script into a specific page in my theme like this: function testimonial_style() { if ( is_page( 4087 ) ) { wp_enqueue_style( 'testimonial-css', get_template_directory_uri().'/...
1
vote
2answers
38 views

Fatal error: Uncaught Error: Call to undefined function test()

So I'm having an issue where I'm getting a 'Undefined function' response and I can't seem to figure out why and how to target it. Relative path to the shortcode file: htdocs/wp-content/mu-plugins/s/...
1
vote
1answer
22 views

Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme

I am trying to use the separate components of the_custom_logo() function to create my own display for the logo. Please can someone inform me as to how I can access the url and the image reference ...
-1
votes
0answers
15 views

Save custom price radio button value in cart and display it on Cart page Woocommerce

I have added custom price on woocommerce single product page using the code below on my theme's functions php: <?php // Output the Custom field in Product pages add_action("...
0
votes
1answer
17 views

Why would one specify multiple arguments when using get_previous_posts_link() which takes only one parameter?

I'm looking at some plugin code that looks like so: get_previous_posts_link(__('<span>&larr;</span> Newer', 'gc-sermons'), $total_pages When I look at the WP function reference for ...
0
votes
0answers
21 views

WooCommerce - Hide products with same title

I need to hide products with same title from shop page. I have many products with different SKU but same name. Is it possible to achieve that with a distinct function like this? add_filter( '...
0
votes
0answers
17 views

Sales report is not displaying all product names and customer notes

I'm trying to work on this woocommerce report that shows only one product name but there is customers order multiple products: Also i want to show customer notes in this report Please help /** * ...
0
votes
1answer
13 views

Changing theme element sign in link through functions.php / child theme [closed]

I have a global element in my themes header. It is a clickable button, when clicked by default it takes users to the login page, i would like it to go to the checkout page. Other than hardcoding ...
0
votes
0answers
13 views

Move to trash custom post type post after ACF Date Picker date is older than today

I have a custom post type called 'aktualitates' and I have a date picker field on the posts from the Advanced Custom Fields plugin with the field name 'aktuali_expire'. I tried adding a code from ...
0
votes
1answer
32 views

Have CSS Class Added with `is_page()` WP function

I have a nav <li> item where I add a page_active CSS class when a submenu page is visited. This works all OK when one of the pages is visited, but I can't get it to add the class when the second ...
0
votes
1answer
23 views

Can't check if a post has thumbnail adding filter to get_post_metadata()

I need to set fake thumbnails to all posts which have yet no a thumbnail. I use the code from the link core.trac.wordpress.org/ticket/40547#comment:1 But I can't check if a post already has a ...
0
votes
1answer
21 views

WordPress function for 1 to for many

I have this function: add_filter( 'prdctfltr_show_filter', 'my_hide_filter_on_category_function_jkbg4iu3b' ); function my_hide_filter_on_category_function_jkbg4iu3b() { if ( is_product_category( '...
1
vote
2answers
39 views

How to pick the default selected value in wordpress dropdown?

First of I am pretty new to this so sorry if this has been asked before but I could not find the right answer for me. I have this dropdown on my website from compare-tech(.)fr I am trying to remove ...
0
votes
1answer
24 views

Wordpress Stock Update Programatically

I'm trying to develop a plugin that would update the stock quantity of products to 0 (Out of stock) that are older than X days. The logic that I'm using is: Select products who's modofied date is ...
0
votes
1answer
23 views

How to override theme's public static function inside of a trait?

I use a theme which has a public static function to display a part of a page like: trait SomeTrait { public static function some_function() { ?> <div class="some_class">Some ...
0
votes
1answer
25 views

Add value to new attribute inside Wordpress menu <li> items

I have this code in my functions.php to add new attribute data-content="" to all my <li> items in the wordpress menu. The value of each data-content has to be different: I would like that each ...
0
votes
2answers
33 views

How do i tweak my wp Post title base on category of the post

Hello please i need a wordpress function.php code where i can choose how to display my title differently in section wp_title. E.g. If home, tag page, Category page, And Pages are viewed then "...
0
votes
1answer
29 views

I cant add is_admin control to plugin

I want to hide my plugin on admin pages because its conflict with that.however when İ add the control, wp says there is critical error. İ want to add this control: if ( ! is_admin() ) { // Runs ...
0
votes
1answer
20 views

Why isn't comment validation working?

I am trying to add Jquery validation to the comments page in WordPress. Everything works except it won't post the fields. May someone help? Comments page: <?php foreach (get_comments() as $...
1
vote
1answer
17 views

Avoid loading css from parent theme

In a parent theme (Foodica Pro) functions.php I have function foodica_scripts(), where css and js are loaded in page header, including: wp_enqueue_style( 'media-queries', get_template_directory_uri() ...
0
votes
1answer
31 views

I can't in any way include css in my theme using functions.php

I can't in any way include css in my theme using functions.php I tried to include css using the link tag, but it only loads it on the first page, then when I go to open other pages (for example the ...
0
votes
1answer
23 views

Loading a plugin's js file from functions.php

I'm trying to change the way a plugin register's its own js file from this: function gpvd_enqueue_styles_admin() { wp_enqueue_style( 'gpvb-admin-styles', plugin_dir_url( __FILE__ )...
0
votes
1answer
12 views

How to escape echo for input tag?

How should I escape echo for this function... function pen_post_sidebar_twitter() { $twitter = esc_attr( get_option( 'twitter_handler' )); echo ( '<input type="text" name="twitter_handler" ...
0
votes
1answer
33 views

Custom WordPress post query for displaying time-released content on website

I am trying to implement a "content drip-style/time released content" subscription system using a WordPress query that filters and selects content from a custom post type using set parameters and ...
0
votes
0answers
24 views

I have an fatal error on my funcyions.php

can someone please help me with this Fatal error: Uncaught Error: Call to a member function main() on null in /home/customer/www/real-amnesti.com/public_html/wp-includes/functions.php:1255 I haven'...
0
votes
0answers
19 views

Is storing in a variable the result of a fonction a most powerful way to code an if structures in WordPress?

In the footer-menus-widgets.php template, from Twenty Twenty theme (by Automatic), we can find a way to code a template and call functions that uses variables to store the result of functions like ...
0
votes
0answers
13 views

How to disable plugin capability : “create new category”

I tested that a capability can be disabled for any user role, but I found nothing to block the capability of a plugin. Is this possible? any help is greatly appreciated
0
votes
1answer
17 views

1500+ duplicate queries via get_option function (query monitor)

I'm having a huge performance issue once I'm logged into Wordpress. Query Monitor says it's doing over 1500+ duplicated queries with the get_option function executing this query: SELECT option_name, ...
-1
votes
1answer
30 views

How do I add schema markup to individual WordPress posts without using plugins?

I'm not a web developer and I'm not a very techie person either, so I'm sorry if any of the following information below wouldn't make much sense. I'm currently trying to add schema markup for ...
1
vote
1answer
26 views

How to remove the embed_footer?

I'm trying to remove the entire embed_footer from WordPress embedded posts. By adding the following code in the functions.php, I was able to remove the site title and comments icon. But still, the ...
0
votes
1answer
21 views

Displaying Logged-In User Name and avatar in Wordpress Menu

I want show the avatar user and username with this code. add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' ); function my_dynamic_menu_items( $menu_items ) { foreach ( $menu_items as $...
0
votes
0answers
19 views

How to get a list of users who like a current wordpress post & remove post dislike & comment like/dislike system

I have the code, the code working fine. But i want modified somethings. //function file add_action( 'wp_enqueue_scripts', 'sl_enqueue_scripts' ); function sl_enqueue_scripts() { wp_enqueue_script(...
1
vote
2answers
30 views

Change dns-prefetch to preconnect with correct protocol

I have this function in my functions.php file: function dns_prefetch_to_preconnect( $urls, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { $urls = []; } if ( '...
0
votes
1answer
24 views

Discount in the specific product title using keyword ( Woocoommerce )

is it possible to create a function that calculates the 10% discount by specifying that in the "Clothing" category all products that contain only the word "shirt" in the title? Or rather is possible ...
0
votes
1answer
33 views

Please show me how to use an if/else statement in combination with wp_enqueue

In my theme I have the following code in my functions.php to enqueue my my stylesheets. function mytheme_styles() { wp_register_style('headerMobile', get_template_directory_uri() . '/assets/css/...
0
votes
0answers
26 views

Function not executing in woocommerce my-account page

I am creating function for user login for my own project. Here is my code add_action('init', 'devsol_customer_login'); function devsol_customer_login() { if ( is_account_page() ) { ?> <form ...
0
votes
1answer
19 views

how can export data in excel file custom plugin

below is my code I need to export data with excel file <form action="<?php echo $_SERVER["PHP_SELF"]; ?>?page=client_plugin" method="post" name="export_excel"> &...
0
votes
1answer
17 views

Get post_author email for Zapier Integration

I'm creating an automation on zapier that allows you to send a notification to the authors of the posts based on the status of the post. Among the various post fields there is no "user_email" which ...
0
votes
2answers
22 views

How to make function appear in sentence?

I have a function to show theme details and want to put it in a sentence. Like: The "theme" developed by "author". And it will contain links. I tried printf, did get the correct result. function ...
1
vote
0answers
14 views

get current date + 90 days and checking every day

User can submit post from frontend submission form. Fieldname: Title (entered by user) expire_date (entered by user) expire_date1 (invisible) expired (invisible) When user enter no value for "...
0
votes
0answers
16 views

Menu not updating for logged in users after redirect

I'm having a problem with my menu not being updated for logged in users. My website has a homepage which I want to change depending if you're logged in or not. I've done this by adding the following ...
1
vote
1answer
36 views

Adding widget to dashboard with wp_dashboard_setup not working

I just separated my functions.php file into smaller files and the required each of those inside functions.php One of those files is 'dashboard.php' where I add a widget to change a notice in my shop. ...