Questions tagged [filters]

A type of hook that provides a way for content to be overridden programatically

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

Filter by category and city for doctors and hospitals in wordpress

I'm working on wordpress medical website which shows all the doctors and hospitals. I'm confused that doctors and hospitals will come as a page or product. I also want to add filter by category (like ...
1
vote
0answers
20 views

Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?

Background: I have a plugin with the purpose of changing up the indexes on some of WordPress's tables to make them more efficient for large sites. The plugin changes some primary and other keys for ...
0
votes
0answers
23 views

The gettext hook doesnt work on text with links

Searched for awhile and looked at the codex https://developer.wordpress.org/reference/hooks/gettext - still cant find an answer. The below function works perfectly when you are on the reset password ...
0
votes
1answer
20 views

Hook add_attachment error

I am trying to optimize my images when uploading to website. I trying to write plugin, that will use hook 'add_attachment' and after attachment uploaded do image converting. add_action( '...
0
votes
0answers
12 views

Show related products by attribute based and certain conditions

Getting a reference here, I want to display a "product collection" on related products based on certain conditions. Example : The product has a color attribute and a size attribute. The ...
1
vote
1answer
111 views

Adding rewrite rule dynamically

I'm trying to dynamically add a rewrite rule that allows one to access any page under an alternate permalink structure of my choosing. So for example, if the alternate permalink structure includes the ...
0
votes
0answers
9 views

Filtering related products by attribute and discounted products

I am looking to filter the default output of the displayed related products on product pages. I need it to only return products with the same pa_merk attribute and products that are discounted. I ...
0
votes
0answers
18 views

How to create a WooCommerce Product filter based on PHP foreach

I am trying to create my own WooCommerce Product Attribute filter, using a PHP foreach. When using the regular WordPress Widgets 'Filter Products on Attribute' every visible product attribute (and ...
0
votes
0answers
21 views

How to make WordPress search page use a relative path

I am working with a WP blog hosted on a subdomain (eg. wp.foo.com). The primary domain (eg. foo.com) is a non-WP platform running a main app/service. For blog content, however, the main platform uses ...
-1
votes
1answer
28 views

Why not showing all post by default in my jquery filter

Hello Expert Developer, Can you please take a look on it, What i did messed up? function mysite_filter_function(){ //groups checkboxes if( $groups = get_terms( array( 'taxonomy' => 'category' ) ) )...
0
votes
1answer
39 views

Why does WordPress strip custom HTML that are form elements and theme SVG icons?

When I add a custom HTML block that only includes form elements e.g. form, input, textarea, etc, WordPress appears to be stripping these wholesale. Similarly, if I add a SVG icon that is part of a ...
0
votes
2answers
15 views

How to debug this search & replace strings snippet?

I add this code (modify from this comment) into my plugin: function wpdocs_replace_content( $text_content ) { if ( is_page() ) { $text = array( 'chamber' => '<strong>...
0
votes
1answer
23 views

Pass debug_backtrace() in Wordpress filter

As you know, debug_backtrace() function has a large output. I need to pass it in my filter. $meta = apply_filters( 'filtername' , $meta , debug_backtrace() ); Does this have a big impact on site ...
1
vote
0answers
62 views

Remove_action does not work

I am using Shopwise theme. In the category pages, the woocommerce shop loop is being used. The template for each product in the list view is retrieved from content-product.php. Here's what I added in ...
2
votes
1answer
157 views

Define a function outside a class and call the function using action or filter hook

Hi Currently i am developing a sub plugin for my own main plugin. Please see the main plugin code below <?php class MyClass { function __construct() { function test1() { ...
0
votes
1answer
17 views

How to Create custom block for displaying information in content section which act like shortcode

I wanted to Display one block which act like shortcode in front and plugin in background. For Example <div class="one-fourth fl glousp-box"> <p class="figure">5000+</...
0
votes
0answers
23 views

apply_filters() and call_user_func() to define and call a function outside a class

Hi Please see the following code of my class class MyClass { function __construct() { $this->autoload_function(); } function autoload_function(){ $my_array=...
0
votes
0answers
15 views

Problem width wp_insert_post_data and Gutenberg block editor

I need to change the post title of a Custom Post Type before save it. I have try with wp_insert_post_data filter and works fine. The problem is that normal posts that uses Gutenberg fires an error &...
0
votes
0answers
12 views

how can I add filter in specfic field in my website?

I want to replace any saudian phone in specfic field in my theme "my-listings" in description and this my script in functions.php: function cudjex($text){ $text = preg_replace('/(009665|...
0
votes
1answer
38 views

Custom Permalink For Custom Post Type - Working Fine But Broken For Pagination

I'm having an issue with pagination not working while trying to get custom post type permalink. I've Custom post type 'songs' and custom taxonomy 'singer' here: example.com/songs/ // ...
0
votes
1answer
16 views

How to apply filter on get_the_post_thumbnail()

my client want me to add a custom fields for thumbail, so the logic will be if custom_thumnail is empty, render the origina. But i don't like idea of writing if statments everywhere + am using SEO ...
0
votes
0answers
21 views

Rewrite image links from attachment id to attachment link

WordPress is having trouble writing links to attachment pages. Sometimes an image links like this: mysite.com/my-post/my-attachment-page Othertimes an image links like this: mysite.com/?attachment_id=...
0
votes
0answers
14 views

Filter widget_posts_args not working

I am trying to use a filter for Recent Posts in a plugin, but it seems not works. I am using inside a plugin: add_filter('widget_posts_args', 'transk_widget_posts_args'); function ...
0
votes
0answers
28 views

Filter wordpress posts without searching the keywords in the post content

We've a courses website where we want to filter posts/courses by the keywords present in the category and/or title. Currently when filtering, the keyword is also being searched in the post content ...
0
votes
1answer
26 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 { ...
0
votes
1answer
17 views

Query filter by value in meta_value array

I try to add a filter to make an elementor post widget displays the posts depending on a certain custom field. The custom field key is adress and contains an array with some keys like street_number, ...
0
votes
1answer
18 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 ...
0
votes
0answers
24 views

Possible to append class to nav menu added to widget area?

I'm wondering if it's possible to add a menu class to a navigation menu added to a widget area? I realize that when adding a menu to a template via wp_nav_menu one can use the menu_class option to ...
0
votes
1answer
28 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,...
0
votes
0answers
33 views

user_has_cap filter allows "edit_others_posts" but not is not allowing updating/publishing

This filter is letting manager users edit specific posts created by other users: add_filter( 'user_has_cap', 'allow_manager', 10, 4 ); function allow_manager( $allcaps, $caps, $args, $user ) { // ...
1
vote
1answer
20 views

best practice for query string values - get_query_var always empty for my value supplied in query string

I'm constructing a form in my WP plugin. I need to specify which records to modify by supplying a value in the URL like so: https://example.com/wp-admin/admin.php?page=my_plugin-event-video-assoc&...
0
votes
0answers
17 views

Variation prices breakdown only for single product page

Hey I'm trying to display breakdown of selected variation price but only on product single page. I dont want to overwite the price but just to show it after the add-to-cat and buy now buttons.For ex ...
0
votes
1answer
53 views

How to filter the source URL of all images on every page

I want to filter the src URL of every image (every img tag) on all of my WordPress pages, with the goal of adding a query string to the end of the image URL. (The reasons why are outside the scope of ...
0
votes
0answers
19 views

Loop order issue with Ajax filter

I'm building a filter with AJAX to sort a custom post type loop. Users can filter the loop using two taxonomies "group" and "area". Some of the args of my CPT loop are: 'orderby'...
0
votes
0answers
11 views

Hide certain product filters from specific product categories

Is it possible to hide certain filters on specific categories? To give an example of the issue that I want to eliminate: We have a category paged called "Phone Accessories for iPhone 12 Pro Max&...
0
votes
1answer
35 views

Remove character from permalink

I searching out for removing a special character from the permalink. Wordpress replaced this character Ø for an o but this is not what I want. If the character is Ø remove this and do not replace for ...
0
votes
1answer
13 views

add_filter postbox_classes multiple post types

I am trying to add classes to my metabox. How could I apply this to both post and pages? $posts variable? Do I need to add filter twice, once for each post type? $id = 'my-metabox-api'; $...
0
votes
1answer
25 views

Is there a way to globallly apply esc_html( ... ) to all inputs and anchors to filter out XSS markup?

I'm new to XSS prevention only 2 years into WP development, so I am hoping there's an easy solution. Installing a plugin designed to prevent XSS abuse is not an option. I need to programmatically, ...
0
votes
1answer
57 views

Custom meta_query order for Elementor based on post meta key [closed]

I'm failing at writing an Elementor $meta_query function so posts will be ordered by meta_value_num of a given key. Each post has a numeric value for the key google_unique_page_views My example is ...
1
vote
0answers
37 views

wp_query 's', search filter with pagination is not working

I made this shortcode for a page of posts. I want to set a search function. I filled for example: "web design". The search-result will set in the var "$catSearched". Then it works ...
0
votes
1answer
29 views

Woocommerce: Complex query in pre_get_posts [closed]

I want to add a complex filtering when getting my products. I have products where some of them are linked to a custom post type. This custom post type has a repeater field. Depending on a cookie, I ...
0
votes
1answer
41 views

Using a filter to change a path

I know this is probably basic Wordpress coding but how would I achieve this? Use the filter “wcvendors_pro_table_display_rows_path” — and return a path to the new template file. (/plugins/wc-vendors-...
0
votes
0answers
17 views

Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters

I have this line in functions.php: add_filter('post_link', function($link, $post) { return str_replace('foo-', 'foo/', $link); }, 10, 2); and now Wordpress successfully sees example.com/foo/bar as ...
0
votes
0answers
31 views

Modify author url display in edit-comments.php

On our site the author url is almost always an IP. I want to show a visual flag next to the IP url if it matches a certain pattern. I just need to understand how to modify the output in the author ...
0
votes
0answers
14 views

How to add a "base" filter for all posts visible to visitors on the site?

I'd like to filter all posts ever visible to my visitors by the posts' custom meta (box) tag value. I added a post meta box "access_required" and I want to check if the post's ...
0
votes
0answers
31 views

auth_redirect() doesn't send users to the page where they orginally tried to acces

In the site I am building, I'm using "theme my plugin" so I could make my own login, logout, registration pages. For the login form, I used the default wp_login_form input names, and the ...
0
votes
0answers
32 views

Best way to fix bad count on All | Mine | Published

I tweaked the default behavior of the post listing page (for a custom post type) via pre_get_posts, the thing is that now the count of All | Mine | Published isn't the right one. I'm aware there is ...
0
votes
0answers
23 views

Counting a WP_Post Object value in an arary, using a filter?

I am trying to check whether a post in the array is the first post with a certain array value. I have a code similar to the one below: Plugin code <?php function my_function() { $...
0
votes
1answer
36 views

Add $args to wp_list_categories

I'm trying to add an argument to wp_list_categories of the Categories Widget: function cat_list_show_all( $list, $args ) { $args['show_option_all'] = __( 'All Cateogries', 'textDomain' ) . '<...
0
votes
0answers
46 views

How to add custom media library mime icons?

Can't seem to get wp_mime_type_icon filter to work so I can use custom image for icons in the Media Library for documents. @birgire answered this post with the following code, but it does not seem to ...

1
2 3 4 5
58