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

get_post() containing gallery is outputting an unmatched closing div at the end of the content

I have created a custom page with fetches content from various posts using get_post(id). I fetch the posts using this function:- function get_my_post($id){ $get_post = get_post($id); $...
1
vote
0answers
8 views

Filter posts in category archive page by year using a dropdown

I'm trying to filter my posts by year in different categories by changing the query using a dropdown with this code: <form method="post" action=""> <...
0
votes
2answers
14 views

Build filter for post-type + multi taxonomies + multi terms

I Need to build an interface with a filter set (a list of checkboxes) that the user can check and click 'filter' to search with in 1 custom post-type for posts with matching terms (there are 3 custom ...
1
vote
2answers
51 views

How to modify an image block in Gutenberg WordPress 5?

Adding images to a post with the block editor: produces the code figure of: <figure class="wp-block-image"> <img src="http://localhost:8888/time.png" alt="alt text" class="wp-image-1391"...
0
votes
0answers
16 views

enable shortcode in woocommerce short product description on archive page

I'm using a shortcode in the woocommerce "Product short description" field. It displays fine on a single product page, but I need it to fire on the archive page as well. On that page, the shortcode ...
0
votes
0answers
6 views

Woocommerce Bookings: change price based upon user role

I'm trying to change the price for bookable products using the Woocommerce Bookings plugin. The price needs to be set to 0 if a user has a specific role. I'm using both the hook '...
0
votes
1answer
9 views

how to overwrite next_post_link

Is there any custom php code that lets me overwrite next_post_link so I can customize it to my liking? I can add code in functions.php Right now it shows next post But I want to show something else
0
votes
0answers
16 views

How to stop echoing gallery inside content?

I want to completely stop echoing gallery inside the_content() because I am showing it in different position outside content as per design (with a help of get_post_gallery_images()). It is a custom ...
2
votes
1answer
20 views

How to specify which category of the post to use in case of multiple categories

In my theme, to display the featured post I have to add an extra category "featured". Now I have articles showing featured in the url instead of the main category. Any help please? Thanls
0
votes
1answer
13 views

Map plugin with proximity search compatible with Buddypress

I need to be able to display Buddypress users on a map while allowing proximity/distance searches but my research yielded in plugins with subpar docs and absence of an online demo to help reassure me ...
0
votes
1answer
16 views

Override filter variable not working

I'm currently trying to override a filter in a plugin. This filter has 1 variable which defines a root path to a folder where some templates are located. This root path is normally in the assets ...
0
votes
0answers
19 views

Modify term slug before saving

I had the same problem like in this Question. Terms like 'c', 'c++' and 'c#' are only saved once with 'c' as slug. Based on example #2 from the answer I built some code that works fine when creating a ...
1
vote
0answers
19 views

What is the downside of using a filter as a “poor man's” dependency injection?

First of all, I don't know whether or not "dependency injection" is the right term to use, what would be "dependencies" in my case are really objects that I use within other "parent". I have a big ...
0
votes
1answer
13 views

Redirecting the lost password page request when using a custon login page

I have a custom login page and hence have setup the following redirects: add_action('init', 'my_redirect_login_page'); add_action('wp_login_failed', 'my_custom_login_failed'); add_filter('...
1
vote
3answers
36 views

How do action and filter hooks understand where to look for the core function that we hooked our function to them

I want to know how does WordPress core files handle the relationship between module and core of the WordPress? We all know it uses add_action() and add_filter() to manipulate data according to our ...
0
votes
1answer
10 views

Removal of Jetpack OG Tags from old blog site

www.beautifulcreationsphotography.co.uk I have a client who used to have a Wordpress blog, however for some reason its carrying over to her new site and causing havok with Yoast. Ive added in this ...
3
votes
2answers
53 views

WP JSON list all permalinks

Scenario I'm considering writing a custom wp-json endpoint to list ALL permalinks for everyone post in my wordpress. Question Is it possible to do this with a rest query + filters? eg. http://...
0
votes
1answer
30 views

Can't properly set the_title add_filter to show short_URL

I am trying to show Bitly's Post short URLs for my blog posts but something seems off as when I am using this code, I see the output all over the page for menu items etc... Additionally, the URL ...
0
votes
0answers
19 views

How to add a block to a category page?

I've got my wordpress site set up to show various menu pages that will feature the content of a category page. I'm curious, is there any way to add a block to the category page? I have a filter that ...
0
votes
0answers
16 views

Add_filter not return any output in custom plugin

I am using WordPress Boilerplate plugin structure to create a custom plugin.Add_action works but add_filter function not returning any output. Here is my code. includes/class-post-rating.php file ...
0
votes
0answers
11 views

Filter past events in post list

I have been looking for a few days, but am struggling to find the function I need. I am creating an events post type for a theme, with the event start and finish timestamps saved in respective meta ...
1
vote
1answer
24 views

Handling Body class based on Template

Through a PHP function, I think I can handle body class, but I think WordPress would have some specific way to handle it. If Home.php then class in the body should be wbody else it should be bgody. ...
0
votes
0answers
21 views

How to use multiple orderby conditions on query search results? (orderby one post type, relevance)

I have a need to sort the search results so that a custom post type "authors" is always at the top, followed by all other post types sorted by relevance. I've found numerous examples about altering ...
0
votes
2answers
48 views

Remove actions/filters that are set with create_function()

This theme I was handed from another dev company is littered with add_action/filter( 'hook/filter', create_function( '', 'return blah('blah')' ); We will be moving this site to a server running php 7....
0
votes
0answers
15 views

Alternative solution for script_loader_tag?

Theme check plugin gives me this error Found script_loader_tag in the file functions.php. Do not remove core functionality. I have used it to defer scripts function add_defer_attribute($tag, $...
1
vote
2answers
41 views

Last updated date function

I want to show the "last updated date" on the front of the post and page. so I add the following code in the functions.php file. function wpb_last_updated_date( $content ) { $u_time = get_the_time('U'...
1
vote
0answers
9 views

How to add an extra variable to login and authenticate it?

I want to add an extra variable to my custom login and to authenticate it to then add it to an SQL database. My custom login: <?php require('wp-load.php'); require('site_config.php'); function ...
0
votes
1answer
16 views

Set Microsoft Word links to open in new window/tab

I'm unable to set Word hyperlinks to open in a new window/tab. Basically, I create a Word document and paste its contents to WordPress, and everything is there, links do work, but they don't have "...
0
votes
1answer
22 views

Wordpress get_avatar filter to match logins

There is get_avatar filter to replace avatar for user with ID 1. It works as intended. https://codex.wordpress.org/Plugin_API/Filter_Reference/get_avatar But is it possible to match avatar for ...
2
votes
1answer
33 views

Wordpress codex: apply_filters - clarification on creating a new hook on the fly. How do we use it?

I have read the WordPress Codex on add_filter and apply_filter countless times, but it wasn't until reading woocommerce source code today that something clicked in the way that maybe I don't ...
0
votes
0answers
12 views

Having issue with dynamic data within restrict_manage_posts function

I have the dropdown dynamically populated with the titles of my podcast post type and I can successfully apply a filter by selected a podcast title and clicking filter. However, when the page loads ...
0
votes
0answers
18 views

Dynamic Dropdown Select Filter with Custom Taxonomy in Custom Posts

I want to create a Dynamic Dropdown Select Filter in my homepage to filter custom posts by parent and sub-categories. The maximum depth for filtering is 4 levels. My Custom taxonomies structure is ...
1
vote
0answers
31 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
27 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
12 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
20 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
23 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
4answers
948 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
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
22 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
18 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
25 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
12 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
21 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
23 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
11 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 ...
3
votes
0answers
114 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 '...
-1
votes
0answers
33 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
17 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
20 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="...