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
1answer
34 views

Possible to hook into Media Library preview File column and use a custom image?

The project I'm working on, I couldn't find an easy way to have WordPress create the thumbnails sizes I needed without tons of waste, nor to simultaneously generate WebP versions, so I disabled the ...
0
votes
0answers
11 views

Hooked into wp_get_attachment_caption to add content to the default description; not working for jetpack slideshow. Why?

I would like to have my image descriptions added to every image caption on my site. No matter where the caption is shown, I would like to have the description prepended, if there is one to this image. ...
0
votes
1answer
38 views

Filter 'comment_notification_text' not working

I am wanting to edit the content that is sent to admins in the comment moderation email notification. I have looked at multiple places and they all seem to give roughly the same example to achieve ...
0
votes
1answer
16 views

What exactly happens to function argument availability when using a filter?

The goal of this question is: to be able to interpret WP docs better to understand what's exactly happening in this scenario to verify what I'm thinking is correct I came across this code. ...
0
votes
0answers
14 views

How to hide a category or tag everywhere EXCEPT for use with get_posts

I am using categories for very short posts (2-3 lines). These posts don't have much value in themseleves, however I use them to setup a complex home page where I have very small sections of content ...
0
votes
1answer
35 views

Remove Author Links

I'm trying to remove the author pages as well as the links to the author pages on my wordpress website powered by Divi. First, I disabled author archives and pages with the Yoast plugin. Then, I used ...
0
votes
0answers
21 views

Adding custom social icons to the social media icon block in the Gutenberg editor?

In wp-includes/blocks/social-link.php there is a function which seems to setup all the selectable icons in an array together with their names and their SVG code (lookie here on GitHub) Is there a way ...
0
votes
1answer
34 views

How to pass a variable between filter/action functions?

In a function fired from filter wp_handle_upload_prefilter, how can I utilise a variable obtained from previously firing action edit_user_profile? My aim: on user-edit.php, when user uploads a file (...
0
votes
1answer
32 views

Wordpress remove_filter not working

The site date has changed from Gregorian date to Jalali with a plugin, and that's good. if (get_locale() == 'fa_IR') { add_filter('wp_date', 'wpp_fix_i18n', 10, 4); } And now I want the date of the ...
1
vote
1answer
77 views

Disable auto-resizing of uploaded images, but only for certain filename

How can I totally disable the wordpress auto-resizing when uploading images, but only for images that have a certain string in its filename. Eg. disable auto-resizing on images in which its filenames ...
1
vote
1answer
111 views

get_current_screen() return null

I want to put JavaScript code on certain pages in frontend. But the output return null . add_action( 'wp_footer', function () { $screen = get_current_screen(); var_dump( $screen ); }, 999 );
0
votes
0answers
31 views

Create Page Template by hook programatically in Functions.php in WP 5.8.1

Create template as file is great. How to do that by dynamic function? What hook, function I need to add dynamic template to dropdown in page. If I won't have access to server files then I stuck - no ...
1
vote
1answer
60 views

Is there a filter called 'network_admin_init'?

Is there a network equivalent to 'admin_init', or what do I have to do to add an action to network admin screens? I use 'admin_init' for an action on admin network screens, but the respective function ...
0
votes
0answers
28 views

Custom SQL query slows down when using multiple OR ... LIKE ... in posts_where filter

I have built a posts query that includes a custom table in search using the posts_join and posts_where filters. Now the customer wants me to include yet another custom table in the search, but doing ...
0
votes
0answers
22 views

Using AJAX to filter posts without refreshing page

I am trying to create a filter to display posts by language (for each category, I have made subcategories to categorise posts by language), however, I cannot seem to get it to work. I have entered the ...
0
votes
0answers
18 views

How to change an image source when rendering on frontend?

when showing articles, let's say there are images with watermark. But of course, those images are somewhere else, the watermark itself is not rendered onto the source image. So, just before rendering, ...
0
votes
0answers
30 views

Filter search query to exclude postmeta value

In my wordpress site I am making use of the pre_get_posts filter to customise my site search query. In functions file I have the following below. Now my issue is, using FieldManager I have added a ...
0
votes
2answers
35 views

Adding overlay search to wordpress using add action/filter

I want to add custom overlay search to my WordPress site using add action. Somehow, it is not triggering the javascripts to show the overlay html. However, it is working in a browser when I test ...
0
votes
0answers
12 views

Create filter like woocommerce attribute filter for custom product page

Hi there I've been tasked with creating a custom filter for a product page where users can choose an attribute and it will only show those products, but I don't really know where to start it would be ...
0
votes
1answer
26 views

the_content getting current page content instead specified ID

I'm using below code to call the_content of a custom post type post, but when I'm run it, it always getting the current page content not the page whose ID specified. It literally duplicate my page ...
0
votes
0answers
40 views

What's the most efficient way to preload multiple font types using links and enqueue?

I added some code to my theme to preload my self-hosted enqueued fonts that are coming in via @font-face. I then added a filter to set the attributes. Seems to work and the pages load a bit faster too....
0
votes
0answers
53 views

How to exclude or include categories in wp rest API without query parameters?

for example I have cat1,cat2,cat3...cat10 in my custom post type. and this is my rest API address for my custom post type: https://example.com/wp-json/wp/v2/mycustompost I don't want to use parameters ...
1
vote
1answer
14 views

How to edit dashboard search posts button texts for my CPT?

I am new to WordPress Development. Can I change texts of filter search box button ?
1
vote
0answers
42 views

How to add a post slug to a url?

For a project i'm working on I try to add the slug of a custom post type to the end of an url. The case: When a user fills out a contact form, the email that gets send needs to have a link to the ...
1
vote
0answers
124 views

How to control WordPress image metadata (using Imagick)?

In short, I'm having trouble with the WordPress Media Library image editor and how it handles metadata. I use the Imagick PHP extension (but also tested with GD for comparison), and in all ...
0
votes
0answers
48 views

Filter the title to only affect the_title() template function

I am using the_title filter to add an HTML snippet under the title, as follows: I only want the output to happen for the main title in the posts or page view. That's why I added an early return to ...
0
votes
0answers
15 views

Support old attachment url scheme after migrating uploads

There is an active site where all attachments are stored in the root of the uploads directory. Many files dramatically affect the performance, so I decided to put them into subdirectories with the ...
0
votes
1answer
33 views

Remove and replace woocommerce add to cart button [closed]

I'm working on a solution where I have a ACF on each WooCommerce product. When the custom field is other than NULL it will add a custom anchor tag below the previous Add to cart button. This works ...
3
votes
0answers
109 views

How to remove unwanted panels inside InspectorControls from core blocks in Gutenberg

If I want to extend the core block I can use Block Filters where I found a filter like editor.BlockEdit. Example from doc: const { createHigherOrderComponent } = wp.compose; const { Fragment } = wp....
0
votes
0answers
23 views

400 bad request in admin-ajax.php file

(function ($) { $(document).ready(function () { $(document).on('submit', '[data-js-form="filter"]', function (e) { e.preventDefault(); var data = $(this)....
0
votes
0answers
16 views

Why is the subcategory redirected to single.php?

When accessing the url site.com/name-category/name-subcategory I want to use a specific template but the Wordpress is understanding that name-subcategory is a post so it redirects to the single.php ...
0
votes
0answers
51 views

How to filter my posts by categories and tags simultaneously?

I need your help with advice for post-filtering in WordPress. I will describe the situation briefly: I created the main categories of posts which I placed in the main menu: Accessories; Exterior; ...
0
votes
0answers
32 views

ACF Relationship Previous Next links of CPT

I have a CPT for artworks with custom taxonomy for artists. Then I have another CPT for artists. The artist pages are basically the the page title (artist name) and a relationship field where you add ...
0
votes
1answer
62 views

How to run php code only for a specific widget on a page and not all widgets on that page?

I want to display extra information below the post title only for the posts widget on the home page and not the portfolio widget. I'm using Wordpress' the_title filter to do this and that works fine, ...
0
votes
1answer
49 views

Woocommerce : Add name filed of checkout page to buyers wordpress display name

We use woocommmerce to sell online courses. also we use a plugin called "Digits" to help users easily login/register using only their mobile phone numbers and OTP sent to them as sms. So the ...
0
votes
0answers
44 views

Wordpress meta_query filter gets stuck

I have the below filters in my wordpress(woocommerce): $meta_query_args = array ( 'relation' => 'AND', array ( 'relation' => 'AND', array ( 'key' => '...
0
votes
1answer
23 views

Use of comment_reply_link_args filter

i am trying to create a filter like this add_filter('comment_reply_link_args','change_author_title'); function change_author_title( $args ) { $defaults = array( 'add_below' => '...
0
votes
0answers
27 views

How to remove all page content?

I'm a beginner at WordPress. I'm trying a code to remove all the content from all the pages/posts etc but it is not working. Plugin Code: function mycustomCode($content){ $content= ""; ...
0
votes
1answer
16 views

style_loader_tag not changing stylesheet to preload

I am trying to change rel='stylesheet' to rel='preload' using style_loader_tag but it isn't doing something. Could anyone please tell me what is wrong with my code? add_filter( 'style_loader_tag', '...
0
votes
0answers
48 views

How to change Gallery image url in product page ? In function.php?

My code is like add_filter('wp_get_attachment_url', function($url){ if(strstr($_SERVER['HTTP_ACCEPT'], 'image/webp')!=false){ return $url.".webp"; }else{ return $url; ...
0
votes
1answer
25 views

post title not changing at post page

I am using following code to change post title but it only change it in all posts list not at post page add_filter('the_title', array($this,'change_title'), 10, 2); public function change_title($...
0
votes
0answers
19 views

Pretty permalink issue wp_query not working properly

I have a custom post and taxonomy. So currently I have this mysite.com/products that show the archive. Next, I have this mysite.com/products/dairy-chilled-eggs(parent term)/ this will give me all the ...
0
votes
1answer
44 views

How to remove get_header From all single pages in wordpress with functions.php without plugin?

I want to remove get_header and get_footer conditionally and temporary from all single pages with functions.php i tried this remove action with conditions code but not works.. remove_action('...
0
votes
1answer
23 views

How can I filter the comment action links so that I can display the actions links based on user capabilities?

I am referring to the action links above. Is there a filter or hook I can use to display these links based on user roles and caps?
0
votes
0answers
17 views

Hide WooCommerce from Admin Menu without Path Access

I am trying to hide the WooCommerce tab admin dashboard. This method works, but the result is it also blocks access any links with the wc-admin path in the url. function pls_hide_woocommerce_menus(...
0
votes
1answer
140 views

Add filter for specific category only

I've been working on trying to hide all other categories from the category widget when a particular category is selected. So, as an example, the site has 5x Products categories and and 1x Services ...
0
votes
1answer
25 views

Is there any way to get list of all possible filter hooks for all post types?

I would like to code a plugin that injects the custom content to any type of post (post, page, product, any others) but I would like to allow the users to let them select the place of content too. ...
0
votes
1answer
60 views

Warning: in_array() null given in PHP function

I'm building a metabox gallery in Wordpress for a specific page template. I have the following warning notice in the dashboard: Warning: in_array() expects parameter 2 to be array, null given in... ...
1
vote
0answers
42 views

Edit incorrect password message WordPress

I would like to edit the text that is displayed when the user enters an incorrect password on my site. The text is in the location \wp-includes\user.php. I have tried editing the file via Filezilla ...
0
votes
1answer
28 views

Two Filter Issue [closed]

I've noticed that on certain pages, two filters appear in the top right. One is styled properly (the bottom one), and the other isn't. I'd like to remove the top one (which isn't styled properly). Is ...

1
2
3 4 5
58