Questions tagged [filters]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
11 views

Replace youtube embed in wordpress

I am using this code to replace youtube video: add_filter('embed_oembed_html', 'foo_embed_oembed_html', 99, 4); add_filter('video_embed_html', 'foo_embed_oembed_html'); function foo_embed_oembed_html(...
0
votes
1answer
20 views

Filter wp_redirect() to stop redirect under certain condition

I am developing a tool to print PHP debug messages on screen. I would like to stop the wp_redirect() function from actually doing the redirect if the debug tool contains a message that it wants to ...
0
votes
1answer
17 views

Access ACF fields within custom preview function?

I'd like to access custom ACF field values from custom_preview() filter? add_filter( 'preview_post_link', 'custom_preview' ); function custom_preview() { // how to access ACF field values here ? }...
0
votes
0answers
7 views

Filters post by subcategory slug using buttons

I load in subpage post with one category now i try filter this post by him subcategory and get link to page some like mypage.com/subpage/?slug=fish after click button and see only fish post. I should ...
0
votes
0answers
27 views

custom error message for empty username and password using authenticate filter not working

I'm trying to override the authenticate to edit the default error message. /** Purposed: Custom Login Error Message Description: This function override the default error message on login form. **/ ...
0
votes
1answer
21 views

How to append to an array and return the results in a filter?

i am trying to get array in filters in wordpress i dont khnow how to do it. add_filter('ft_tabs', function ($tabs) { return array_push($tabs, array( '111' => 'aaa', '222' => '...
1
vote
1answer
57 views

Randomize attachment IDs

I'd like to have my attachments IDs being random (not sequential). Just like what this plugin does, but for attachments. I've tried to look into the source code of the plugin, but it uses filters that ...
1
vote
1answer
17 views

How to add 'total' value to custom column title on the posts list page

I have added custom column to all posts page by this code: // ADD NEW COLUMN function len_columns_head($defaults) { $defaults['post_len'] = 'Symbols'; return $defaults; } // SHOW POST LENGTH ...
0
votes
0answers
10 views

How to sort products in shop page by defined category order?

I am currently working on sorting the shop page products based on a defined category order and stock count. I got the stock count sorting working but I am unable to find a proper way to implement sort ...
0
votes
1answer
20 views

How would I go about replacing this function in my child theme located in inc/template-tags.php

How would I replace this function that lies inside inc/template-tags.php in my parent theme function theme_navigation() { ?> <div id="theme-nav-container"> ...
1
vote
0answers
24 views

How to link the whole list item in Gutenberg's latest posts block?

I am using a Gutenberg's 'Latest Posts' block on my front page. Featured image display and grid layout are enabled in the block settings. By default, only the post title is linked to the actual post. ...
0
votes
0answers
14 views

Removing comment lines from all enqueued js files using a filter function

Is there a way to filter all enqueued javascript files and remove all comment lines without using a plugin ?
0
votes
1answer
27 views

Display/Filter post using if else statement

Here it is: I want to filter my post based on category (Party) If the post with category Party has tag which is 'event', it is the one that will display If there is no ''event' tag, only the recent ...
0
votes
1answer
34 views

How to stop Wordpress from completely overriding my <img> tags in my templates?

I'm busy with a Wordpress theme and in some templates I use images (like home.php). I do the calculations for the srcset and sizes for every template/image individually and store the urls and values ...
0
votes
1answer
22 views

Adding an item to an anonymous array inside a filter?

I'm trying to add a user_role inside the ATUM stock management plugin. Currently it's only visible to admins, while I also want to add shop_managers. But I just can't succeed in adding it successfully ...
0
votes
0answers
17 views

Add an attribute to the root from functions.php with add_filter

I followed this link. First thing I did was to add my dark-mode switcher, add JS to handle it and edit my CSS accordingly. Thing is, I didn't exactly do that, I used the possibility to have a global ...
0
votes
0answers
11 views

Set a numeric range for post ID generation based on post type?

I'm wondering if there's any way to configure WordPress to assign post IDs like so: Pages ID range: 10000 to 19999 Posts ID range: 20000 to 29999 Custom post type 'A' ID range: 30000 - 39999 Custom ...
1
vote
1answer
41 views

How to get an array of years from all of the search results, and use it to filter by year the paginated loop?

I hope this is not too dumb: even though I'm learning at an acceptable rate, my WP knowledge still has some important gaps. What do I have: My search.php template gets its results from the normal ...
1
vote
1answer
27 views

Modify a Filters Second Parameter

I have this filter: $post_arr = apply_filters('insert_product_post_data', $post_arr, $data); add_filter('insert_product_post_data', 'my_filter', 10, 2); function my_filter($post_arr, $data) { //...
0
votes
1answer
33 views

Would like to use hook or filters to customize email templates

I hired a contractor to help me with my site a few years ago when I didn't have the coding experience that I do today. The contractor ended up making new templates for almost every email, and they are ...
0
votes
1answer
28 views

Ajax filter - show all results that contain at least one filter

For a project I use Timber (TWIG) with WordPress. I'm trying to implement ajax filter with tags on a video template. But it doesn't work like I would like. For the moment my system is too strict. ...
0
votes
0answers
20 views

How to filter menu of categories on attribute archive pages

The following PHP displays menu of WooCommerce product categories: <?php $orderby = 'name'; $order = 'asc'; $hide_empty = true ; $cat_args = array( 'orderby' => $orderby, 'order' ...
0
votes
0answers
15 views

Moving beadcrumbs to different part of the page with hook and action

I am using the Avada theme, and WooCommerce. This is mostly a question about hook / filter syntax and usage. I need to move the breadcrumbs from the normal place, inside the page title bar, another ...
0
votes
0answers
16 views

Use apply_filters to fetch value in another function

Is it possible to fetch apply_filters value some other place like a global variable? function one(){ $value = 'default'; .... some functionality to set $value return apply_filters( '...
0
votes
2answers
43 views

Removing menus from users other than the administrator

I want to remove some of the menu links from all users except the administrator. How can I do it?
0
votes
0answers
10 views

How do I create a button, that when clicked, will navigate to my woocommerce store page and automatically apply specific attribute search filters?

How do I create a button, that when clicked, will navigate to my woocommerce store page and automatically apply specific attribute search filters? The tools at my disposal are Divi for front end, ...
0
votes
1answer
20 views

How to edit post meta data before publishing the post it self wordpress?

I've a custom field in a custom post type whose value I want to calculate dynamically before publishing the post itself for the first time and this custom field gets stored in the postmeta table. How ...
1
vote
2answers
60 views

Show only geolocated user country into Woocommerce checkout country fields

What I'm NOT trying to do: Remove or hide checkout (billing/shipping) country fields What I'm trying do to: Show only ONE country in checkout (billing/shipping) country fields, depending on ...
0
votes
1answer
15 views

Add a div of content within the_content after a certain block

In gutenberg I have several blocks: paragraph heading paragraph code paragraph In php I'd like to find the code block and append content after the block. I'd imagine I need to use add_filter and ...
0
votes
1answer
54 views

WP_Query filter by custom meta

I try to make a page to list users with a meta values. I search to get all users with a site url or user_description Thx
0
votes
1answer
43 views

Want to filter only parent post in admin area

I want a filter like this in my custom post "books". This filter should only bring up the parent post.
0
votes
1answer
20 views

Filter in Custom post type to find the parent post

function fws_admin_posts_filter( $query ) { global $pagenow; if ( is_admin() && $pagenow == 'edit.php' && !empty($_GET['my_parent_pages'])) { $query->query_vars['post_parent'] = ...
0
votes
1answer
17 views

Get current user data

I do work on filter posts by current user, but in my dropdown list, i can get only all users list, but I need to see only the current user function getСurrentUserForFilter(){ $res = ''; $...
0
votes
1answer
51 views

Multiple Tag Filtering

I am writing a theme for Wordpress and I need a tag filter tool for posts, that can filter by multiple tags simultaneously, without a submit button, no checkboxes, no radio’s, and a show all posts ...
0
votes
1answer
78 views

Hook for changing excerpt content when excerpt not set

Title says pretty much all of it. I need a filter that I can use to change excerpt content for those posts that have no excerpt set. Now, I've tried both the_excerpt and get_the_excerpt, they both ...
0
votes
0answers
25 views

How can I override add_filter function which uses $this?

My goal is to change the registration email sent to new users. However, overriding the function responsible for sending the email does not work.. The relevant file in the parent theme folder looks ...
1
vote
0answers
11 views

Change post order random through out the entire WordPress

Is it possible to write a filter on global WP Query so that everywhere on WordPress site - all posts will be shown as random order? It will be applicable for any page like home page, blog page, ...
1
vote
1answer
23 views

How to remove SKU's from ALL products in Quick View - already remove from each product page

I have added code and removed sku's from all product pages (not admin) and all went well. However I realised that if I click on Quick View on any product - the sku's are still there. Can you please ...
0
votes
0answers
17 views

Ajax Product filter by category “no product found”

I know this is a big question but i'm struggling with this for too long without any improvements because I know very little things about coding. I'm trying to create a "simple" ajax product filter ...
0
votes
1answer
46 views

How to wrap all titles generated by Gutenberg “Heading” block with <span> tag

Gutenberg is still relative new concept, so I lack experiences (and the Internet lacks good tutorials). My goal it to wrap all heading titles generated by Gutenberg's "Heading" block with the <span&...
0
votes
0answers
10 views

Gensis Framework (parent): Neither remove_filter() OR filter override function working

I've been able to determine that a bug on my WordPress site is coming from the following code inside the widgetize.php file of my Genesis Framework parent theme: add_filter( '...
0
votes
1answer
46 views

Override woocommerce loop-start.php from theme using plugin?

My theme has an override for /wp-content/themes/THEMENAME/woocommerce/loop/loop-start.php. I want to override this file using a plugin. I understand it can be done using a child theme, but I want to ...
0
votes
0answers
5 views

Add text before anchor link for product menu item type

I'm working on a nav menu that includes WooCommerce Products for part of the menu items. I am looking to add the WooCommerce thumbnails to the menu items that are products, but I can't seem to find ...
0
votes
0answers
16 views

Add #primary at the end of navlink permalinks on single posts

I'm trying to add #primary at the end of the permalinks to the previous- and next post on all single post pages, to jump past the header directly to <div id="primary"> when going to the previous ...
0
votes
0answers
21 views

woocommerce swatch variations filter gallery on select

I am using Variation Swatches For WooCommerce plugin to add variation images to product colors. It's working fine for now, but the problem is that I am also showing all the product's gallery beside ...
0
votes
0answers
33 views

Limit Media Library Access to Specific Folders

I have a site that will host about 100 "Clubs". When users are created, I am assigning them a "Club Leader" Role that identifies them as being a part of a club in general, but I am using a custom meta ...
0
votes
0answers
13 views

Alphabet filter for last name

I'm trying to filter my professionals directory by last name using ajax. Right now I have other filters working using custom taxonomies and a drop down menu, but am having a hard time finding ...
1
vote
0answers
12 views

How to filter post content and force every link (<a>) made in blocks to return urldecode(<a>) with readable value?

Will really appreciate your help with something. I'm using non English letters in my URL slugs. So every time I add an internal or external link with non English letters to my post (via blocks editor ...
0
votes
1answer
24 views

post value to function with Ajax and jQuery

This is how you would create a custom smart tag in wp forms: function ea_custom_smart_tags( $content, $tag ) { if( 'my_smart_tag' == $tag ) { $value = 'Testing 1 2 3'; $content = ...
0
votes
1answer
54 views

Permalink slug no longer editable when using post_type_link filter

I want to customize the output of the permalink for a custom post type, but I want the permalink to still be editable when editing a post. I'm using the post_type_link filter: add_filter( '...

1
2
3 4 5
54