Questions tagged [filters]

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

839 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
1answer
9k views

AJAX with loop filtering categories

I've been researching on how to make my loop with AJAX. I found some codes online and modified some parts but I can't seem to get it to work. This is my code for the loop: <article id="main" ...
7
votes
1answer
485 views

static variable loop not working in Wordpress

I have a function in my wordpress theme that deletes the first embedded video in a video post. See code below. This is in the functions.php file. /* - function that hides first video in post content -...
6
votes
0answers
2k views

How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table <td> elements?

I'm trying to allow users to paste (relatively) simple tables into Gutenberg. The editor converts the raw HTML fine but strips out any attributes/classes. For the most part this is good - I want to ...
5
votes
0answers
472 views

Prevent 404 when using pre_get_posts to filter an archive page

I have added a custom taxonomy named "area" to the default "post" post type. It's meant to organize posts by geographical area. In category pages I've added a dropdown that allows the user to filter ...
4
votes
0answers
386 views

Remove left alignment option in core/image block

I’m trying this code to disable the left alignment option from the core/image block. I just want to make available the center and right alignment options. wp.hooks.addFilter( 'blocks....
4
votes
0answers
219 views

Customize WordPress Media Manager - Media Window

Im trying to customize the wordpress media manager "add media" window to get it as simple as possible to use. So i want to disable/ hide the following fields/ functions because i dont need some or ...
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....
3
votes
1answer
144 views

How to remove "out of stock" variation options from size dropdown in woocommerce?

I'm using woocommerce to display products and their variations. I have a variation called 'Size' for all of the products. Some of the variations are out of stock, but these are still showing in the ...
3
votes
1answer
48 views

How can I add a fifth option to the alignment picker?

I'd like to have the following options in the image alignment picker: Left Right Center Full None Obviously four of those are there by default, but the "full" one doesn't currently exist. The idea ...
3
votes
1answer
649 views

Set Item Order with wp_nav_menu_{$menu->slug}_items

I have some code that adds a menu item to a menu using wp_nav_menu_{$menu->slug}_items. It's pretty easy to add a menu item as the first or last item of the menu, but I was wondering if there's ...
3
votes
0answers
416 views

How to display term description in empty terms archive?

I list all terms from a taxonomy, even the empty ones, but I found out that at least in 2010/2011 themes I got a 404-like message, the default seems to only display the term description when at least ...
2
votes
1answer
1k views

Is there a Woocommerce hook that fires when applying a coupon but before checking if it's valid?

I want to add an item to the cart (that same item gets discounted with the coupon) upon using a coupon code (with a hook). E.g. when using the coupon code SAMPLECODE, a product is added to the cart ...
2
votes
0answers
32 views

What's the point of the query_vars filter?

WordPress doesn't seem to support named parameters in a query string (like ?foo=123&bar=456) unless you explicitly allow them by doing add_filter('query_vars'...). Why is this? What (presumably ...
2
votes
0answers
21 views

How can I filter block registration based on post-type? (Block alignment settings)

I want to disable the .alignwide and .alignfull block alignment options (remove them from the editor UI) on the 'post' post-type only. I have tried using this block registration filter to modify the '...
2
votes
0answers
162 views

Gutenberg disable the "block" tab in right sidebar

I'm working on a Gutenberg setup that allows only one classic block. I want to disable the "block" tab in right sidebar since no settings appear there anyway, but can't find a hook or way to achieve ...
2
votes
0answers
316 views

Extend core block attributes in post content

I need help with adding attribute 'caption' of core/image block into saved post content. Currently saved attributes look like follow: <!-- wp:image {"id":36,"sizeSlug":"large"} --> I aim to ...
2
votes
0answers
90 views

How to remove get_post_metadata using remove_filter inside a class?

This is the filter that i use. add_filter('get_post_metadata', array(WPKWP::CLASS_NAME, 'get_post_metadata'), 10, 4); I have to use the get_metadata inside the above call back function. If I use ...
2
votes
0answers
67 views

Rewriting Woocommerce Product Filters To URL Segments

I'm working with a site where product category pages are filtered using query parameters: ?color=red&brand=nike&size=10 I'd like to use URL segments instead and rewrite the request to the ...
2
votes
0answers
226 views

wp_insert_post_data filter not working correctly after upgrade to Wordpress 5

I have the following code in a project. function vb_post_modified_date_update($data, $postarr) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if (!empty($...
2
votes
1answer
838 views

Hide some items from Screen options in dashboard for products

I am trying to unset/hide some options in dashboard. I am trying it for products screen. Here is the screenshot Here is the code i tried to hide SKU /** Hide Dashboard widget by default via Screen ...
2
votes
2answers
806 views

How To Change The Html of Products filtration sidebar in Woocommerce?

I have Used the function dynamic_sidebar('sidebarId') in the sidebar.php file. and all the functionality of the sidebar is Working succsessfully My Question is How To Change the Html of the sidebar ...
2
votes
0answers
88 views

Multilanguage URLs

I am trying to achieve multilanguage behaviour for my website. I'm very close but not quite there and feel like I'm running in circles. That's why I decide to ask for your help. I'd like to use URLs ...
2
votes
0answers
2k views

Filter custom post type archive page with custom taxonomies (categories) with AJAX

I've created a custom post type (projects) with different custom taxonomies (projects' categories). I would like to create a categories' filter but with AJAX, so without reloading the page every ...
2
votes
1answer
175 views

where to apply "apply filters" and other Sanitization Functions

I got to learn something new today here on this post. I have code written for a Post widget → <?php class chimp_post_widget extends WP_Widget { function __construct() { ...
2
votes
0answers
490 views

Add guid filter to attachment in media library grid mode

I'm trying to show in media modal box, attachments from a specific folder in my website and, correct me if I'm wrong, the best way to proceed is a like filter on wp_posts field GUID. Something like ...
2
votes
0answers
38 views

How to filter out post type meta?

I have used this code to filter out the post type and it works fine when showing filtered results: add_filter('wpseo_title', 'vehicle_listing_title'); function vehicle_listing_title( $title ) { ...
2
votes
0answers
376 views

Change file name from wp_generate_attachment_metadata

I'm pretty new and just have a hang on how wordpress data flows internal. I am confronted with applying a b/w filter on upload. no problem. I found the wp_generate_attachment_metadata filter and ...
2
votes
1answer
204 views

How to use IF Statement in WordPress?

I can't see how to correctly use the PHP if statement in my filter function below. This code works perfectly if all (3) of my $_POST inputs have values however it has a fatal error if any are empty. ...
2
votes
1answer
420 views

How to get all the predefined do_action() calls from an active theme

To hook my plugin content into anywhere, suppose I offered the theme developers to create their own hooks with a prefix (pre_) anywhere in their theme - the rest of the hook is unknown to me. So what ...
2
votes
0answers
1k views

Run oembed separately outside the_content()

I have this structure for my content.php : <div class="featured"> <!--featured image here--> </div> <h1 class="entry-title">Post Title</h1> <div class="entry-...
2
votes
0answers
2k views

How to set a custom path, for ajax image upload folder in admin?

I am coding my first Wordpress plugin that handles some data for a custom (shop-like) post type. It also has an image uploader within a metabox, where you simply drag in your images and it ...
2
votes
0answers
932 views

Pass parameter to the upload_dir filter

I'm trying to figure out a better way to pass a parameter to the function I am using with the upload_dir filter. Currently I have only gotten it to work by using sessions and/or cookie that I erase ...
2
votes
0answers
2k views

Changing image URLs in media library

On a default wordpress install, the media library is located at: /wp-admin/upload.php. I am trying to update the image URL to point to my CDN, not my local server. This filter add_filter('...
2
votes
1answer
391 views

Trying to wrap <span> around first word of multiple word strings with a widget_title() filter, only works on two word strings and not more than two

I am trying to wrap a around the first word of multiple word widget titles. I have used the answer from here: https://stackoverflow.com/questions/10263792/revised-wordpress-function-to-put-a-span-...
2
votes
1answer
524 views

Proper use of the_content filtering

This is a bit difficult without posting scads of code, but my question is: What are the benefits of filtering through apply_filters('the_content', 'anything');, and given my example loop, am I ...
2
votes
0answers
456 views

Querying posts with meta value that begins with a certain pattern

I am trying to create a search filter using meta_query. The only problem I'm having now is that I can't compare with wildcards. I think that's how you word it? $keyword = 'sos'; $tlds = array('com','...
2
votes
1answer
2k views

Refine/Filter WP_Query Posts with jQuery or Ajax

I know this has been asked many many times, but I literally searched for an answer for more than 5 hours without finding anything that drives me in the right direction. What I'm trying to achieve is ...
1
vote
0answers
19 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 ...
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 ...
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 ...
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 ...
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
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 ...
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 ...
1
vote
0answers
78 views

How do I add custom bulk actions to multiple custom post types?

I'm following this tutorial to add custom bulk actions to my dashboard but I have multiple custom post types. So far I was able to achieve what I want with // functions.php // The same line for each ...
1
vote
0answers
160 views

How to filter for user registration, be able to throw error message

I'm setting up a woocommerce/woprdpress site. Upon checkout, a user is created in the system. I want to take the user data and create the user in our external systems (both proprietary db and auth0). ...
1
vote
0answers
84 views

html tags in gettext hook get escaped

Hy everyone! Here I found this code function gb_change_cart_string($translated_text, $text, $domain) { translated_text = str_replace("original string", "modified string", $...
1
vote
0answers
18 views

How to create 'Local' filters for WordPress srcset sizes in template parts?

I've read a bunch of tutorials on how to create filters for srcsets and srcset sizes, but they all appear to be applied globally, with a fixed width or set of widths for sizes. The trouble is, I pull ...
1
vote
0answers
26 views

How to filter meta_values using REST API

i am able to get the data by make an API called with these args ?meta_key=frequent&meta_value=day are there any possible way to filter with multiple meta_value? i already tried meta_value=day,week ...

1
2 3 4 5
17