Questions tagged [filters]
A type of hook that provides a way for content to be overridden programatically
2,894
questions
0
votes
0
answers
7
views
Same URL for portfolio and for a page creates 404 error. Is there any filter that i can use for a child page?
What I try to achieve is to have the portfolio slug as a page slug also, and when I will assign the page as a parent to another, then that page must look for a specific page's parent ID and return the ...
0
votes
1
answer
18
views
can't modify post title using the_posts filter
I tried to modify post title and content, content is modified in output, but title stays intact:
function filter_the_posts( $array , $oQuery) {
...
$array[0]->post_title='new title';
$...
0
votes
1
answer
25
views
Prevent posts with certain post_meta to be edited
So I am looking at adding some custom post_meta to posts and I want those posts to not be editable, which will be some content that I am pulling in.
Here is what I have:
I have solved the issues when ...
2
votes
1
answer
99
views
Find variables available at a given hook
I'm hoping for a simple way to tell/find/echo what the available arguments are available for use at a given hook.
For example —
function example_function($something){
//do stuff with $something
...
4
votes
1
answer
56
views
How can I register a new REST context?
I'm using the REST API to get datas from Wordpress within my React App.
I've seen that you can filter the responses Wordpress returns by using the filter rest_prepare_{$this->post_type} documented ...
2
votes
0
answers
25
views
How do I replace a render_callback function for a block?
I like to basically use a modified version of the below function.
There is pre_render_block and other filters. I have not found out how to get attributes and context the exact way that function does.
...
0
votes
1
answer
18
views
Why does admin_body_class not work?
I'm trying to add the body class of the current user role to both the frontend and the admin backend.
Why does admin_body_class not work for admin?
The comment to this question does not work: How to ...
0
votes
0
answers
16
views
How to fix select filter on category
I created a filter where I can filter on different types of machines by a custom taxonomy. It shows the right taxonomies in the filter and after submitting the right url is shown. Problem is that ...
0
votes
0
answers
16
views
How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
My requirement is to create a survey in wordpress, and the user needs to log in before answering. But the login page uses our own business account, so we created a login page ourselves (using .net ...
0
votes
0
answers
19
views
Want to create custom design of progress indicator in wpforms
Is there any way to create custom design of progress indicator of multistep form in wpforms. By default wpforms has three templates to chose from. I have chosen progress bar which has design like this
...
1
vote
1
answer
38
views
if role is logged in then do something
I need some pro eyes please.
Over all, I'm adding one button/link to the MAIN NAV depending on the logged in role.
I have this “working” code:
if ( ! function_exists( 'add_extra_item_to_nav_menu' ) ){
...
0
votes
1
answer
33
views
How to sort WooCommerce products page by latest in-stock items first?
How to sort the WooCommerce products page by latest in-stock items first and all the out-of-stock items to the last?
Currently, I'm using a code snippet from "https://www.businessbloomer.com/...
0
votes
0
answers
25
views
Filter sub-category from checkbox form
I’m having have a checkbox filtering issue in wordpress - Please have a look at the details below - Any help would greatly be appreciated!
What I’ve built:
I created three custom taxonomies of topics, ...
0
votes
1
answer
25
views
wp_dropdown_categories() works correctly but the list is not filtered in admin for custom post type. What is the problem?
When the filter is executed the correct query is passed as
edit.php?s&post_status=all&post_type=banner&action=-1&m=0&banner_cat=31&filter_action=Filter&paged=1&action2=-...
0
votes
1
answer
17
views
How can I add a filter for specific categories on functions.php?
Hi,
I am on functions.php and I want to add this filter:
function graphene_alter_the_query( $request ) {
$dummy_query = new WP_Query();
$dummy_query->parse_query( $request );
if (!...
0
votes
0
answers
14
views
Replace Data In Post & Update Meta Field Post Is Saved
I'm a bit lost & I'm wondering if someone can help.
I have a post that is being generated from a podcast feed. That feed contains an audio player using the <audio> tag. I wanted to remove ...
0
votes
0
answers
9
views
post_orderby filter breaks function
I have a custom shortcode function to display a list of articles. The list needs independent styling based on the post tag. That part all works. I need it to be sorted by term_order. I created a ...
0
votes
0
answers
19
views
How to add filters to my site?
I've just started to use Wordpress for a few days to build a website. How can I add customizable filters to my site?
I'm using a free version, if this requires a payment? Which ones should I choose (I ...
0
votes
0
answers
34
views
conditional filter
I'm trying to set up a filter that shows upcoming events (if any) or shows past events;
function events_function($date_args){
$date_args = array(
'post_type' => 'evento',
'...
0
votes
0
answers
15
views
Filter Media by attached page or blog post in Library
I am trying to create a filter using restrict_manage_posts that will filter all media according the page or post type that have been attached to. Actually i need to create a filter that refers to the ...
0
votes
1
answer
49
views
Disable Remember Me in Login Form
I need to disable the 'Remember Me' prompt in login screens.
Based on answers here https://wordpress.stackexchange.com/a/306746/29416 (including my own answer from 2018 with code that I had working ...
0
votes
1
answer
14
views
custom filtering admin columns
i'm trying to add custom filters to a CPT job-offer, for example, i'm starting by locations. the filters works fine except when i try to filter by all locations.
this is my code
function ...
0
votes
0
answers
13
views
How to stop DOMDocument destroying embeds?
I am making use of PHP's DOMDocument to carry out two DOM operations on the post content, by filtering the_content:
Wrap a certain element pattern in a div.
Add a class to a particular element.
The ...
0
votes
0
answers
21
views
'manage_users_custom_column' is a filter, but 'manage_posts_custom_column' is an action. Why?
I've been implementing some custom columns in admin tables for a Wordpress project, and I was caught out by the differences between manage_users_custom_column and manage_posts_custom_column (or ...
0
votes
2
answers
27
views
Filter content for get_the_content()
I Need to filter content for posts. If the user is not logged in, then the post content should display "please log in....". If he is logged in, then he can see the post content.
I wrote the ...
1
vote
1
answer
91
views
How to add numeric slug for child page in WordPress 5.9?
I am trying to configure WordPress 5.9 to allow numeric slugs for child pages. Drawing from the 2015 answer to a similar question I took the up-to-date code of wp_unique_post_slug, removed || ...
0
votes
0
answers
22
views
Is it better to use a constant or apply_filter?
I'm using WPML, which has several ways to access the current language.
ICL_LANGUAGE_CODE
if( ICL_LANGUAGE_CODE === 'en' ){
// Do stuff
}
apply_filter( 'wpml_current_language', null )' docs
$lang = ...
0
votes
0
answers
14
views
How to register dynamic settings in WordPress Customizer?
I have been experimenting with the Customizer JS API to create Panels, Sections, Settings and Controls in the Customizer. Till now, I have been using the PHP API but decided to try the JS API for the ...
0
votes
0
answers
19
views
Display posts ONLY from the current logged in user and current week/year/month Elementor posts
I want to show the posts my users have added in three different sections. That would be "Your Posts from This week" and so on. I am currently using:
add_action( 'elementor/query/currentuser',...
0
votes
0
answers
32
views
How to show ACF fields in Gridbuilder custom block
I'm using GridBuilder WP (great plugin, average support) to show a grid of a custom post type. Ultimately, I need to show an ACF taxonomy field, and their support have recommended using one of their ...
0
votes
0
answers
4
views
comment_notification_text filter not working
I want to customize notification for post author when comment is posted.
My code in functions.php is :
//add notifications when comment
add_action( 'wp_insert_comment', 'wp_notify_postauthor' );
//...
0
votes
1
answer
33
views
sortable columns for multiple custom post types not working
I have two custom post types named professor and campus.
To each of these CPT's I have added two custom admin columns named image and last_modified, which currently display correctly on both CPT's ...
0
votes
0
answers
20
views
Line Breaks are stripped off when direction property is found
The line breaks are stripped off when the p tag has a dir attribute inserted, to explain further I'll list some examples.
Let's say we have 2 lines of text as following
<p>Text Paragraph Number ...
0
votes
0
answers
10
views
How to optionally append components to the output of a gutenberg block?
I've been using block filters to update the core/embed block, and so far have added a couple of extra attributes and various controls to the edit method, but have stumbled on an issue when extending ...
1
vote
0
answers
24
views
How can I remove the kses filters when saving a specific post type ? (it breaks my JSON)
I want to store JSON in my post_content, but the kses filters makes it break.
I would like to remove the kses filters when creating or updating (well, saving) a specific post type; anywhere in the ...
0
votes
1
answer
37
views
Use a hook or filter, or overwrite this Gamipress function?
Currently, Gamipress allows you to import a CSV file that lists a username (email or ID), and a points value to add to the points type for that user. It uses this function to achieve this, which ...
0
votes
1
answer
15
views
How do I add a line break to a string that is output by PHP?
There is a heading output in my ad statistics page (WordPress):
<h3 id="ad-title"><?php printf( __( 'Statistics for %s', 'advanced-ads-tracking' ), $ad_name ); ?></h3>
I ...
0
votes
1
answer
35
views
I need to add a filter to prepend the term 'National - ' to the post title if the post is tagged to multiple states
I am trying to add a filter to add the word "National - " to the beginning of the the post title if the post has multiple states that it is in.
Here is a screenshot:
I just figured out the ...
1
vote
1
answer
18
views
Remove style `?ver=` from `/wp-admin/upgrade.php`
Using style_loader_src hook to remove the version query works just fine, but on /wp-admin/upgrade.php the version queries won't go away.
Is there a way to also remove the versions strings from the /wp-...
1
vote
0
answers
17
views
How can I remove a function that has been added to wordpress with add_filter?
to begin with I am trying to modify a wordpress plugin.
I have created a function named fuxia_is_the_best. Then I add this function to the sanitize_title filter, with the use of this code:
add_filter('...
0
votes
1
answer
18
views
My combination of 'post_type' and 'tax_query' not working?
I want to filter search results by custom post type and custom taxonomy terms, the result is here:
add_action('pre_get_posts','search_filter');
function search_filter($query) {
if($query->...
0
votes
0
answers
22
views
Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
Very much hoping that somebody can help me out.
Currently creating my own Ajax Post Filter, using https://rudrastyh.com/wordpress/ajax-post-filters.html as a template. Is it possible to split one ...
0
votes
0
answers
12
views
Show only posts with titles/permalinks that do not contain certain words
I want to show only posts with titles/permalinks that do not contain certain words, for example, the word "how-to".
it is possible to do that and how?
This is my current code to show all ...
0
votes
1
answer
21
views
Add hook after content without formatting
I want to add a table after the_content with a hook, but it's adding <p> tags in certain areas. This is a plugin, I don't want to remove <p> tags from all the_content, just the table I'm ...
0
votes
0
answers
11
views
How to display a warning when an uploaded image is too small?
I want to display a warning when a user uploads an image with too low a resolution. I don't want to block the upload, just give a warning.
The only option I see is wp_handle_upload_prefilter, but ...
0
votes
0
answers
23
views
How to convert Currency from USD to other IP Based currency in Php function
I am trying to implement a feature on Paid Membership Pro Subscription plans that can automatically change the plan currency to user's IP Based local currency and price can also be converted ...
0
votes
0
answers
30
views
How do I make these combination select filters work when only one dropdown is set? They work in Wordpress 5.8.2 but don't in 5.8.3
I have a custom post type: 'insight'. I have 5 custom taxonomies: insight_service, insight_type, insight_month and insight_year. I'm using a form with select dropdowns dynamically filled with the ...
0
votes
0
answers
49
views
How do I display main query posts in random order using add_filter
So I tried two methods to simply display the main query posts in random order - simple. I'm also trying to understand all this better.
Using the_content add_filter, with my own instance of WP_Query ...
0
votes
1
answer
26
views
Why template_include filter does not work with WPML plugin?
I have some issue with WPML. I use two different product page fro the phisical product and for the video lessons. Now I added one more language to the project ussin WPML plugin. And It's okay but my ...
0
votes
0
answers
17
views
Scanning for custom embed and prefetching
I have an embed which is essentially a script and a div (so not an oembed) which can easily be added via the html block. I'd like to be able to slip a prefetch link conditionally into the head when ...