Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [filters]

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

868 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
1 answer
655 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 -...
danny471's user avatar
  • 191
7 votes
0 answers
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 ...
Tommy Ferry's user avatar
6 votes
0 answers
662 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 ...
Andreyu's user avatar
  • 253
6 votes
0 answers
246 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 ...
public9nf's user avatar
  • 386
5 votes
0 answers
560 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....
kanlukasz's user avatar
  • 504
4 votes
1 answer
375 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 ...
cinquecentooo's user avatar
4 votes
0 answers
1k 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....
elvismdev's user avatar
  • 300
3 votes
1 answer
443 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 ...
SohaIb AhmEd's user avatar
3 votes
1 answer
5k 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 ...
lastnoob's user avatar
  • 153
3 votes
0 answers
109 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 '...
ChemicalSailor's user avatar
3 votes
1 answer
53 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 ...
JacobTheDev's user avatar
  • 1,231
3 votes
2 answers
771 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 ...
Jeremiah Prummer's user avatar
3 votes
0 answers
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('...
David Register's user avatar
3 votes
0 answers
472 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 ...
Diana's user avatar
  • 1,238
3 votes
1 answer
766 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 ...
orionrush's user avatar
  • 910
2 votes
0 answers
148 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 ...
O. Jones's user avatar
  • 471
2 votes
0 answers
301 views

Gutenberg - Add align controls to a custom block

I want to add align controls to a custom block. I wrote this code thad adds the code that adds the default block alignment toolbar to the block, but I select and change the align, I get an the ...
BenB's user avatar
  • 795
2 votes
1 answer
213 views

To add a custom filter based on a meta field

i want to filter posts from a custom post type in admin based on a meta field. i tried several ways ( here, here and here). It works in each case, BUT i have to click twice on the filter button. At ...
PGrafiek's user avatar
2 votes
0 answers
116 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 ...
equin0x80's user avatar
  • 143
2 votes
0 answers
355 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 ...
BenB's user avatar
  • 795
2 votes
0 answers
394 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 ...
Tomáš Vavřinka's user avatar
2 votes
0 answers
169 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 ...
user avatar
2 votes
0 answers
154 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 ...
Daniel Dewhurst's user avatar
2 votes
1 answer
418 views

Remove a div from RSS feed

If someone can help to remove a div from my RSS feed. I want to remove below code from my RSS feed. <div class="well"> <a class="btn" href="foo.com">foo</a></div> Thanks in ...
veggera's user avatar
  • 21
2 votes
0 answers
333 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($...
Vallel's user avatar
  • 121
2 votes
2 answers
1k 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 ...
Ali Beshir's user avatar
2 votes
0 answers
205 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 ...
racanu's user avatar
  • 21
2 votes
0 answers
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 ...
Crashy's user avatar
  • 199
2 votes
1 answer
212 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() { ...
WordCent's user avatar
  • 1,867
2 votes
0 answers
646 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 ...
user114036's user avatar
2 votes
0 answers
40 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 ) { ...
joe city's user avatar
  • 139
2 votes
0 answers
564 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 ...
Isfirs's user avatar
  • 21
2 votes
1 answer
263 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. ...
Mike's user avatar
  • 21
2 votes
1 answer
350 views

wp_upload_bits Upload Specific Sizes Only

For images uploaded using this code, I want to only upload the full-size image and the thumbnail (whereas for images uploaded through site, I want all sizes). However, I can't figure out how to make ...
Pamela's user avatar
  • 161
2 votes
1 answer
639 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 ...
Mayeenul Islam's user avatar
2 votes
0 answers
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-...
Billy's user avatar
  • 249
2 votes
0 answers
3k 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 ...
Raphael's user avatar
  • 53
2 votes
0 answers
1k 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 ...
Levi's user avatar
  • 175
2 votes
1 answer
426 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-...
Leon Francis Shelhamer's user avatar
2 votes
0 answers
457 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','...
naruzshadow18's user avatar
2 votes
1 answer
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 ...
Jaypee's user avatar
  • 337
1 vote
0 answers
11 views

wp reset password page - head inline script

In the reset password page, i have this core inline script in the head section : <script type='text/javascript'> /* <![CDATA[ */ var userSettings = {"url":"\/","uid&...
rafa226's user avatar
  • 121
1 vote
0 answers
21 views

add_filter( 'user_has_cap','my_function', 10, 3 ); and call to get_users in my function triggers an infinite loop in user list

I use: add_filter( 'user_has_cap','my_function', 10, 3 ); In user list to allow users to edit only a specific list of users with a meta user identical to a current user connected. To get the list of ...
Alejandro Antolinez's user avatar
1 vote
0 answers
29 views

Custom updater to change plugin version

I have a custom plugin hosted on github, and had previously had a plugin updater class that would poll the repo for the 'latest' version. Now the plugin is on multiple sites, but we want the option to ...
ConBran's user avatar
  • 111
1 vote
0 answers
36 views

Possible to overwrite load_template function in plugin using functions.php

So, I am currently using a Wholesale plugin for Woocommerce which, by default, redirects users to it’s own Wholesale Store page. The caveat is that the Wholesale Store page only uses the archive-...
jayciemota's user avatar
1 vote
0 answers
10 views

Adding custom filter not working

this maybe a stupid question, when I’m trying to create a custom filter to hook into later and filter and return something, I don’t get any results. I am testing this in the themes functions.php //...
Aldo's user avatar
  • 11
1 vote
0 answers
29 views

Core/Image access caption in render_template and in wp.hooks

I am making an override to core/image block -disabling styles, changing markup and such. I have managed to solve some things, but struggle with some others. Here is my code: filters.php <?php use ...
Sam Tyurenkov's user avatar
1 vote
1 answer
26 views

WP "optimizing" PNGs into thumbnails 5X larger than originals - FIX

As I am about to add over 50,000 product photos to a site in development, I am more than concerned about the thumbnails being generated and “optimized” by WordPress. Between WordPress, Woocommerce, ...
Swapot's user avatar
  • 11
1 vote
0 answers
30 views

How do I add a filter to my custom post type archive page?

I used the guide HERE from acf themselves, but for some reason whenever I attempt to query anything at all in the url I get the "There has been a critical error on this website" error. $...
judahking's user avatar
1 vote
0 answers
32 views

Using send_password_email filter after wp_update_user

I have created a custom plugin that will provide some custom user roles that are named customers and operators. When an user will create a new account, I've created some logics that imply that ...
ICTDEV's user avatar
  • 133

1
2 3 4 5
18