Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [filters]

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

0
votes
0answers
7 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($...
0
votes
0answers
20 views

How to display custom seo title before the loop?

So I've optimized one of my archive page title to this add_filter('wpseo_title', 'new_filter_title'); function new_filter_title($title) { if ( is_page('1637') && $...
0
votes
0answers
11 views

VAT Number in WooCommerce Emails - if empty dont't show

Is it possible that the NIP label and company name will not be displayed in the e-mail if the customer does not provide them. I use this code: add_filter( 'woocommerce_email_order_meta_keys', '...
0
votes
0answers
9 views

Add category to curent category filter - link

I want to place a link to a category (cat2) on the page MySite.com/category/cat1/ that takes you to MySite.com/category/cat1+cat2/ But if you already are on MySite.com/category/cat3+cat1/ I want it ...
0
votes
0answers
11 views

meta filter and taxonomy filter on custom taxonomy template

http://192.168.178.17/property/city/mohali/ city is my taxanomy template i want to add filters in query string for taxonomy, category and meta data how to add filter
0
votes
0answers
16 views

Modify oembed code conditionally

My users have sprung a requirement on me that I am having some difficulty figuring out. I've tied myself up in knots trying to unravel the the logic needed. The original spec of this website I am ...
1
vote
1answer
10 views

How to validate recaptcha on comments form?

I've added the following code to my function file to add the recaptcha, however I do not know how I can validate the captcha. /** * Add Captcha to Comments Form */ add_filter('comment_form', ...
3
votes
2answers
704 views

How to disable Gutenberg editor?

As the 5.0 is getting real, and so is Gutenberg... Is it possible to disable Gutenberg and use previous TinyMCE editor? How to do this?
0
votes
0answers
31 views

is_search() and ?s search parameter missing in url

Found this code: add_filter( 'posts_where', function ( $where, \WP_Query $q ) { if( ! is_admin() && $q->is_main_query() && $q->is_search()) // No global $wp_query here ...
0
votes
0answers
21 views

How to filter a page title with custom taxonomies

I'm trying to hook a page title using is_page() and its ID 1637 along with two taxonomies serie and area. But I can't get it to work. am I missing something code: add_filter( 'wp_title', '...
0
votes
2answers
20 views

Adding id and class to the search input in WordPress search form

I want to apply the AJAX feature to the WordPress custom theme for search. And I need to target the input using id and class. I didn't find any tutorial on adding id to the premade WordPress search ...
0
votes
1answer
16 views

How would I be able to use a font awesome icon as a user's avatar?

Would it be possible to use/allocate a font awesome icon as a user's avatar?
2
votes
1answer
22 views

Filtering by Category doesnt paginate correctly on the backend

Description of Issue Right now, on the Wordpress Admin Dashboard, we have 300 posts in our blog. 250 of those posts are in the category "Blog". We're trying to filter the posts to only show posts in ...
0
votes
0answers
9 views

Create drop down menu with the child categories of a category

I'm trying to create a drop down that has the child categories of a specific category as options. This is my PHP: $args = array('child_of' => 88); $categories = get_categories( $args ); foreach($...
0
votes
0answers
14 views

Wordpress: Issue with filtering users using date range

I'm trying to add a date range filter for wordpress admin users table to filter users that have posted ads between the selected range. I've managed to add the date range inputs. I have 2 issues with ...
0
votes
0answers
19 views

add_rewrite_tag broke permalinks that doesn't use that specific tag

I have a custom post type that I'd like to have a permalink slug based on its taxonomy. All the posts of this CPT have one, and only one, term always marked on this specific taxonomy. That's my code: ...
1
vote
0answers
10 views

How to properly modify WP Vary or any existing headers?

I have a site that currently have a some part of the headers like: Vary: Accept-Encoding, Cookie I want to modify it to be: Vary: Accept-Language I tried the suggestions here using this code ...
2
votes
0answers
36 views

Edit srcset and sizes attributes in Gutenberg image, cover and gallery - blocks

I am looking for a way to adress the responsive srcset and sizes attributes on Gutenberg image blocks - like image, cover and gallery. Usually one would do this with the '...
0
votes
0answers
25 views

Filter for body_class in template-part not working

I'm using the following snippet to add body class in different files, amongst others in page.php add_filter( 'body_class', function( $classes ) { return array_merge( $classes, array( 'dark' ) ); }...
0
votes
0answers
13 views

Hide posts from all posts lists [duplicate]

I just start a new blog, and I want to import all my old posts. But I want to list them in a separate page (named 'Archive') and not show them in the main page, 'Recent posts', most commented and so. ...
0
votes
0answers
16 views

How can newlines be filtered from post content?

How can newlines be filtered from post content using: <?php add_filter( 'the_content', 'filter_function_name' ) ?> or, if better, removed at the time the post is published or updated? Any ...
1
vote
1answer
16 views

Filter oembeds tags to modify iframe attributes

By default, when putting another WP url inside a post/page, it oEmbeds it and produces a blockquote and iframe code with the default in the front-end: <iframe class="wp-embedded-content" sandbox="...
-1
votes
1answer
24 views

How to filter part of a variable if it is no array?

I was wondering if it is possible to filter out a part of a variable, if it is no array. Or can I only replace the whole code, or add code to it? Let's say I have this code: $output = '<...
1
vote
0answers
20 views

How can I made custom taxonomies relationship?

I create two custom taxonomies: Category (Cars, Pets etc). Region (New York, Washington etc). Now I need to do archives like {Category} in {Region} (for ex. Cars in New York) and get slugs for it (...
1
vote
1answer
18 views

Is possible add icon in title posts only in specific tag?

I want to add an icon in title posts only in posts with specific tag. Is this possible? I've already tried these codes, but they didn't solve my problem: Approach #1 if (is_tag('162')) { ...
0
votes
0answers
5 views

Additional filters on the taxonomy page

I can't find the way how to add the additional filters to the taxonomy page. I will be grateful for the advice.
0
votes
0answers
8 views

Comments show perfectly on regular posts, but won't display on custom posts

As the title says, I'm seeing no comment entry fields for custom posts, but they're working just fine for standard posts. In my functions.php: function custom_post_register() { // creating (...
0
votes
0answers
12 views

wp_nav_menu() filter - preg_replace value returned wrong

I'm having an issue where the filter I've added to wp_nav_menu() is adding code to the second level of the navigation. How can I change the filter or the preg_replace code in a way that only adds it ...
0
votes
2answers
18 views

Remove an action by extending class and replacing it

I'm trying to override a method (my_packages) from the WP Job Manager Paid Listings plugin by extending it's class from within a custom plugin Here is how the source code (none-related code removed) ...
0
votes
1answer
15 views

pricefilter without WooCommerce

I have custom post-type for products (with AFC filed price) I don´t have WooCommerce installed. But I would like to sort my products by price in a price filter. Any ideas how can I achieve that or ...
0
votes
1answer
15 views

Add_filter when value is no variable?

Let's say I have an function like: function cc_get_content_preview() { return apply_filters( 'cc_get_content_preview', get_the_excerpt(), 55 ); } Here get_the_excerpt() is the $value that I can ...
0
votes
0answers
20 views

What is the recommended way to save errors / warnings / user messages from actions / filters for custom display in the frontend?

This is a very basic question and there are a lot of solutions to it - however what is the recommended (or at least a good) way? Problem statement: While processing a request to a WordPress project ...
0
votes
0answers
14 views

Woocommerce filter don't work

I noticed that some Woocommerce filter not called as needed. For example in cart view page must work filter 'woocommerce_get_item_data' but this filter not works, I wrote code in theme functions.php ...
0
votes
1answer
22 views

Using add_filter inside another class

I'm building a plugin which generates custom css, I have 2 classes: The main class, with core functions The compiler class as following (I simplify everything, because there is a lot of options): ...
0
votes
1answer
30 views

Add custom category name as data-filter to switch between these categories

I have a portfolio page where I would like to place three buttons that will switch between different categories. I am using data-filer to sort them into different projects. I am thinking, how can I ...
0
votes
1answer
22 views

Does anybody know what the $current_screen ->id for customizer.php is?

I searched high and low & tried a bunch of different things but I still wasn't able to add inline css to the customizer.php page. I usually employ page id $current_screen ->id === " " for ...
0
votes
1answer
29 views

Don't prepend WordPress base url to image paths

I'm programmatically adding image attachments to posts, however I'm not uploading the image, just storing the full url which is hosted on a CDN e.g. https://i.atcdn.co.uk/imgser-uk/imgser-uk/servlet/...
0
votes
0answers
18 views

Only show grouped products until products are filtered then show simple products

Currently I am using css to hide ".product-type-simple" and show ".product-type-grouped" and when filters are set then hide the grouped and show simple. It works but with problems due to pagination. ...
0
votes
1answer
23 views

Add view to admin menu to filter for specific criteria ( If post is child of specific Parent )

add_filter('views_edit-page','addFilter'); function addFilter($views) { global $wp_query; $query = array( 'post_type' => 'page', 'post_status' => ...
0
votes
1answer
25 views

Output all terms slugs for a loop filter

I have created a filter on a custom post type loop using terms slugs just like that : <li><a href="#" data-filter=".<?php echo esc_attr( $cat->slug ); ?>"><?php echo esc_html( ...
0
votes
1answer
24 views

Displaying posts on a page that have been assigned a value in a database

I have a wordpress site with a bunch of posts that I need to display on a page, depending on their value in a database. To be more specific, out of 20 posts I would only want to display the posts on ...
1
vote
1answer
16 views

Accessing parameters when adding filter

I am trying to change the out put of wc_get_rating_html using this filter apply_filters( 'woocommerce_product_get_rating_html', $html, $rating, $count); So far this function works and of course ...
0
votes
0answers
13 views

Remove action from plugin in another not working

I have 2 plugins with same structure. Let say plugin A and plugin B. They are generated with WORDPRESS PLUGIN BOILERPLATE GENERATOR (https://wppb.me/). I have some php (and ajax) methods in plugin A, ...
1
vote
2answers
15 views

Where to add_filter in theme functions.php?

I am new to Wordpress and want to make some changes in the content of a plugin page. I have found out that the same can be done using add_filter I have the filter value for the plugin content that ...
0
votes
0answers
14 views

WP_Query with meta_query with two clause and Search&Filter Pro

I have custom post type job, which has one custom field chceckbox named top_job and it has only one choice Top job. There will be always only one Top job. I need to display this one top job always on ...
0
votes
0answers
16 views

Filter page results for custom post type - custom field

I use gravity forms to allow users to submit their own blog posts and I have a custom field in that for country. I am wondering how this would look like to make this happen where a user can have a ...
0
votes
1answer
22 views

WooCommerce Tax Filter Not Working

I'm using the official docs here: https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce and their snippet below to create a threshold trigger so that orders below $110 are not taxed. ...
0
votes
1answer
24 views

Replace Text with hyperlinks

I would like to replace few words in the content of the posts. For example. Original: Here is my test string. Which Need to Replace First Test word in the string. Excepted String: Here is my <...
0
votes
0answers
35 views

How to create a filter for custom post type in the dashboard?

So I have a product custom post type and would want to create a filter for the categories like what's in woocommerce page. Am not using woocommerce so I just want to replicate that feature. I've ...
0
votes
0answers
29 views

Wordpress Query to show children of the current post using Elementor to design the page

I am trying to create a custom query to show the children of the current post. I am use the custom post type "services" and using Elementor as the theme builder. Elementor requires the query to be ...