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

WordPress notification if new post published

I use WordPress and I want to alert users if new post with post_type = job_post was published. Also I want to show amount of new post. So I add to function.php global $new_job_count = 0; function ...
user avatar
0 votes
0 answers
21 views

wordpress built-in Jalali date convertor

I'm developing a new plugin for a client and he wants dates to be in Jalali. As I changed language of WordPress to Persian, the posts date automatically changed to Jalali. So I Think maybe WordPress ...
user avatar
  • 101
0 votes
0 answers
21 views

Possible to override plugin function?

I need to override the behaviour of a function in a 3rd party plugin but there is no filter and the function is not wrapped in an... if ( ! function_exists( 'function_name_here' ) ) { Is it possible?...
user avatar
0 votes
1 answer
24 views

Disable autosave with `function.php` for custom post wordpress?

I need disable auto save with function.php in wordpress. What should I do? Thanks
user avatar
0 votes
0 answers
11 views

Add "Free from x€" to flat rate shipping method

I've ran into a problem where shipping method "Flat rate" is set and also it's rate. I need to add some custom function to extend it's possibility to check the cart for x amount of spend ...
user avatar
  • 1
0 votes
0 answers
11 views

sort metabox columns in listing Single

Hello WordPress community! I modified an existing meta box which is page_attributes. I grafted it to the articles and it allows me to give an order to the posts. I want to add the column to the ...
user avatar
0 votes
0 answers
18 views

remove specificly the last <p> tag in all posts

How to remove the last line of content in all of my WordPress posts, which always have its own tag <p>...</p>? Ex: <p>content I want to keep</p> <p>line I want ...
user avatar
0 votes
0 answers
9 views

How to Redirect Buddypress Directories To Login Page For Non Logged in Users

How to Redirect Buddypress Directories To Login Page For Non Logged in Users? I'm also using the Yuzify plugin. It gives a code for it, but it's not working on multisite. Can anyone modify this code ...
user avatar
0 votes
0 answers
6 views

How to set value selected using select2 jquery plugin

In my file, i have small html bellow: <div class="dropdown-mul-2"> <select style="display:none;" name="dom767_options[all_posts][]" id="mul-2" ...
user avatar
0 votes
0 answers
6 views

bp-custom.php is not working on a WordPress multisite environment. how to fix it?

I'm using the youzify plugin. It has an option: if you want to add a custom code, you need to create a file named bp-custom.php in the WordPress plugin root folder. And youzify provides some code on ...
user avatar
1 vote
0 answers
21 views

How to combine wordpress_logged_in cookies in one cookie?

I'm trying to optimize my server to consume less resources as possible and increase overall performance. In my site I don't see a need to recompute same requests for users or guests every time. The ...
user avatar
  • 111
0 votes
0 answers
15 views

load more button duplicates previous products [closed]

Here is my handler to ajax request. What is my problem? function loadmore_ajax_handler(){ $args = []; $args['paged'] = $_POST['page']; $args['posts_per_page'] = 3; $...
user avatar
0 votes
1 answer
42 views

WordPress login set cookie that survive browser exit (wp_signon function)

I've read all the relevant question here on StackExchange and I haven't found a solution. Here's the problem: I use a plugin to use Google OAUTH to login in Wordpress. All working correctly, but I can'...
user avatar
0 votes
1 answer
19 views

How to stop media_sideload_image from running when deleting a post?

I have a code that downloads an image and saves it to the media library when you save a post that uses a certain block. The code runs perfect but downloads the image again if you delete the post. How ...
user avatar
0 votes
1 answer
16 views

Reset postdata not working on WP_Query in functions.php

I'm running a WP_Query in my functions.php, so I can easily access some ACF-fields in my code without having to run that query on every page. However, the loop changes the post ID to the CPT I'm ...
user avatar
  • 279
0 votes
2 answers
17 views

Filter nav menu items HTML tags and wrap inner text with span

I am using the following filter to select <a> tags from a specific menu that have no attributes (href, class, etc.) and replace them with <button> tags. add_filter( 'wp_nav_menu_items', '...
user avatar
0 votes
0 answers
9 views

Woocommerce order status payment

I have some issue with Woocommerce client already do the payment, but then i see as order pending payment, but this should be in order status processing thats the default settings
user avatar
0 votes
0 answers
15 views

Customise Grouped Product display in Woocommerce with custom column

I am trying to display the grouped product where i need to display REF and SKU/Part Number in the table as shown in the screenshot from another website i have seen. By default it only shows the ...
user avatar
0 votes
0 answers
21 views

WP Container Displaying Only on First Page of Archive

I have the following code for a two-column container: <div class="rh_content rh_content_above_footer rh_page__content"> <div class="wp-container-3 wp-block-...
user avatar
0 votes
1 answer
20 views

I want to display latest post in marquee [closed]

<?php /* Plugin Name: Breaking News */ function rif_breaking_news(){ ?> <div class="breaking_news_box" style="background: none repeat scroll 0 0 #2E8B57;...
user avatar
0 votes
0 answers
44 views

wp_nav_menu displaying all pages

As the title says, I'm using wp_nav_menu in header.php to load in the audience, secondary, and main menus and when I do, every menu contains every page - or at least many more pages than I selected ...
user avatar
  • 1
0 votes
1 answer
24 views

WordPress 6.0 upgrade caused my custom function to stop working

Not working on WordPress 6.0: https://thealliance.health/for-providers/resources/provider-news-archives/ Working dev site on WordPress 5.9.3: https://ccahdev.wpengine.com/for-providers/resources/...
user avatar
  • 1
0 votes
1 answer
31 views

Add php code to wp_print_scripts?

Is there a way to add inline php code to the editor using wp_print_scripts? I'm trying to find a way to display text from a php string into a value of input of a block. Here's my code: function ...
user avatar
0 votes
0 answers
16 views

Getting text from custom field from customizer

So I've created a panel in the customizer section in WordPress to add the phone number to the site. It works fine in the back end but it wont show up in the front end here is my functions.php ...
user avatar
  • 5
0 votes
0 answers
21 views

Dynamic URL Rewrite for Custom

I have a custom post type called Hotels which I woud like to link to using the below url structure: /{country}/{state}/{hotel-name} I am fetching and inserting posts dynamically, so I do not know the ...
user avatar
1 vote
0 answers
16 views

How to change or add user role after getting post request data about pay? [closed]

How to change or add user role after getting post request data about pay? qiwi2.php file in theme folder: <?php include($_SERVER['DOCUMENT_ROOT'].'/wp-load.php'); $qiwi = [ "public_key&...
user avatar
0 votes
0 answers
44 views

Workaround for og:image unsupported webp image type, Yoast SEO?

My site Beta Fox uses Yoast SEO plugin to help deal with SEO common practices, however an issue has arisen. In beginning of last year WordPress didn't fully support webp image types, neither Yoast SEO....
user avatar
  • 111
0 votes
0 answers
15 views

How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes '&' to '#038;'?

I use a quick redirects plugin and it's changing my URLs after the fact and thereby breaking some of my links. I never want wordpress to change & to #038;. There is an unwanted solution to turn ...
user avatar
  • 130
0 votes
0 answers
7 views

How to change the author box selection on a post to a custom taxonomy

So instead of the author section pulling in 'Users', I need to change it so that the author box displays a selection of the terms from a custom taxonomy I have made. Is this possible to change?
user avatar
0 votes
0 answers
22 views

Modify WooCommerce used to get all orders in dashboard

The existing WooCommerce orders table in the wp-admin dashboard orders the results by the date the order was made, but I want to modify the query to order by date and also by the shipping method of ...
user avatar
  • 101
0 votes
1 answer
30 views

Let current user know pending posts counts using wp_query

I'm working on a query to let a logged-in user know if the user has more than 5 pending posts. Here's what I ended up with: // Start the query $query = new WP_Query( array( 'post_type' => '...
user avatar
  • 175
0 votes
0 answers
17 views

How to remove/hide collapse menu for user/subscriber?

I want to remove/hide the collapse menu item from the dashboard for user/subscriber role only. I don't want to remove it from the admin dashboard. I am the code below to remove it entirely which was ...
user avatar
0 votes
2 answers
22 views

Cannot get wpdb data (Error in a simple fuction) [closed]

I'm using Cryto Plugin and want to get coin price data from plugin db. For easy practice, I'm trying to get BTC data. <?php function get_coin_price($coin_symbol) { global $wpdb; $coin_price = ...
user avatar
0 votes
1 answer
18 views

How to check post meta isset or not empty during publish/save post?

How to check if a specific post meta isset/!emtpy during updating or publishing a post ( save_post() )?
user avatar
0 votes
0 answers
32 views

redirect after submiting post for review

I have a frontend page that allows "Tutor Instructor" role, to create a course and this course is a custom type post called courses, when the Tutor Instructor finishes creating the course he ...
user avatar
  • 3
0 votes
1 answer
30 views

How to inherit field value from parent post into in child / sub post

I have created a custom post type, called 'centres'. This CPT is hierarchical, ie, I can create child pages under each custom post. Centre1 Location1 Contact1 Centre 2 Location2 Contact2 I've ...
user avatar
0 votes
0 answers
16 views

How to avoid saving empty data to sql while using add_meta_box

I'm trying not to save empty data (null) while using add_meta_box function. My code is /** * Register meta boxes. */ function hcf_register_meta_boxes() { add_meta_box( 'hcf-1', __( 'Hello Custom ...
user avatar
0 votes
0 answers
10 views

Output product category link from WP_Query

I have a WP_Query that outputs products from given Product category name. For each product list I would also like to link to the category of that product, but I'm not sure how. My query: <?php $...
user avatar
0 votes
0 answers
14 views

How to implement Polylang functions in my theme's php file?

I am translating a site with Polylang that was created by someone else using a custom theme. Some strings couldn't be found by Polylang, so I need to manually register them for Polylang to see. Now, ...
user avatar
0 votes
0 answers
16 views

How to make WooCommerce payment method field optional?

Here is my current code on a plugin. /** * Field Validation. */ public function payment_process() { if ( 'woo_bkash' !== $_POST['payment_method'] ) { return; ...
user avatar
0 votes
1 answer
16 views

How to assign php file(template) to several pages with same prefix page name/slug

Can I assign WP php file (specific template) to several pages with same prefix name/slug using (if is_page(){}) ? If it's possible it could be useful. Is there a php function to do like css selector : ...
user avatar
  • 11
0 votes
0 answers
26 views

Unzip file in functions.php, and add it to cron

I have a file in the root folder of my wordpress installation (myfolder, wp-content, wp-config, and all other). I want unzip a test.zip archive in my myfolder folder in root directory. I try this ...
user avatar
0 votes
0 answers
20 views

How to Display WooCommerce Product Price in WooCommerce Archive

I have created a custom function to display 2 custom fields (ACF) and the price of the product after the item in the WooCommerce Archive/Shop page. My Custom fields are show, but I am unable to get ...
user avatar
  • 106
0 votes
1 answer
24 views

Adding onload to body for certain pages

I am looking for a function to add <body onload="prepareFrame('https://airtable embed URL here')"> to certain wordpress pages only. I know how to add a custom body class but not an ...
user avatar
  • 638
0 votes
0 answers
32 views

How to change text color depending on the number value (Using javascript)

I'm trying to change text on the table depending on the meta value I give (number). if meta value >= 7, number text on table changes to green. else if meta value >= 4, number text on table ...
user avatar
0 votes
0 answers
17 views

is_main_query() always returning false

I've built a Wordpress site using Oxygen builder. I'm using the 'Post Types Order' plugin to control the post order. I have an Archive Page for a custom Post Type. For the Loop/Oxygen Repeater I'm ...
user avatar
  • 101
0 votes
0 answers
23 views

Change the behaviour of a button

I'm using Flatesome theme and I have a use case that I need to refresh the page after closing the popup, I'm wondering if I can change the behavior of the close button in Lightbox Popup so instead of ...
user avatar
0 votes
0 answers
14 views

Disclaimer that will show every refresh of the page

Hello I have here a code that is based on a "where you first access the page you will see the Disclaimer template" but I want it to show every time I refresh the page <?php // ...
user avatar
  • 1
0 votes
1 answer
78 views

How to get an attachment id from a filename

I have not been able to find a reliable solution for how to lookup the id for attachments in the media library from a filename as Wordpress does not appear to provide such a function. Most solutions ...
user avatar
  • 79
0 votes
0 answers
15 views

Woocommerce Variable Product Dropdown for Custom Shop Template

I'm building out a custom shop template and I'm trying to achieve something like this. Where the user can choose the product variation in the dropdown, choose quantity, and click add to cart without ...
user avatar

1
2 3 4 5
112