Articles of filters

WordPress removing slashes from shortcode output

I’ve got a problem, what I’m trying to do is passing a url through a shortcode and use it as a background image, the problem is that the url gets processed and all the slashes gets removed. I tried removing the wordpress filter remove_filter( ‘the_content’, ‘wpautop’ );) but it doesn’t seem to make any difference. […]

Create a pre-filtered version of the Media Library

I have that rare thing, a group of contributors who worry too much about copyright. To encourage them to use the media library, I want to provide them with an alternative version of the library that only shows licensed images. I label these with an attachment category, ‘Licensed Stock Images’. I thought I could make […]

Filter the regular price of woocommerce products

Want to filter the regular price of woocommerce products. Based on product id and their meta data I want filter the get_regular_price of that product Something like this. function filter_woocommerce_get_regular_price( $array, $int, $int ) { return $array; } add_filter( ‘woocommerce_get_regular_price’, ‘filter_woocommerce_get_regular_price’, 10, 3 );

Get the name of menu item with wp_nav_menu

Basically I’m customizing the menu through the options of wp_nav_menu(). Here is some of my code: function custom_novice_menu($args) { $args[‘container’] = false; $args[‘container_id’] = ‘my_primary_menu’; $args[‘link_before’] = ‘<div class=”topic-card”><div class=”topic-circle”></div><span></span><h3>’; $args[‘link_after’] = ‘</h3></div>’; return $args; } Essentially I want to get the name or ID of the current menu item. That way I can use […]

Secondary Navigation Menudisappeared When using wp_nav_menu_items

My Secondary Navigation Menu works fine until I use add_filter( ‘wp_nav_menu_items’) to add a login / logout button to my primary menu. Here is my code: add_filter( ‘wp_nav_menu_items’, ‘add_loginout_link’, 10, 2 ); function add_loginout_link( $items, $args ) { //Add item to primary menu if ($args->theme_location == ‘primary’) { //checks if user is logged in if […]

How include css class based on post ( in loop ) slug?

I’m using this function to retrieve body and single post classes from their slugs. add_filter( ‘post_class’, ‘fl_pages_bodyclass’ ); add_filter(‘body_class’,’fl_pages_bodyclass’); function fl_pages_bodyclass($classes) { if (is_page() || is_single() ) { // get page slug global $post; $slug = get_post( $post )->post_name; // add slug to $classes array $classes[] = $slug; // return the $classes array return $classes; […]

Print url to default featured image

I’m trying to setup a fallback image for featured image. The main problem I have is miss of filter for get_the_post_thumbnail_url(). I’m using this function to echo thumb url in many-many templates, because it is easy customizable. So, this is not a solution to make an if-condition for each usage. And even to set default […]

Filter categories of posts with checkboxes

Hello guys I’m trying to make simple filter options for my WordPress project. I want to do it with checkboxes. It looks like this: This is the code for checkboxes: <div class=”categories”> <?php $cat_count_web = get_category( ‘8’ ); $cat_count_marketing = get_category( ‘3’ ); $cat_count_uncatagorized = get_category( ‘1’); ?> <h3 title=”<?php echo $cat_count_web->count; ?>”> <?php echo […]

Remove Editor From Homepage

Im trying to remove the editor from the homepage using the following functions however I am struggling to achieve this? function hide_homepage_editor() { if ( is_admin() ) { if (is_front_page()) { remove_post_type_support(‘page’, ‘editor’); } } } add_action( ‘admin_init’, ‘hide_homepage_editor’ ); another try: function hide_homepage_editor() { if ( is_admin() ) { $post_id = 0; if(isset($_GET[‘post’])) $post_id […]

Add/remove CRON action depending on variable

I’ve hooked a function on to a CRON job called ‘job_manager_check_for_expired_jobs’, and I want it to run based on the value of a variable $create_sitemap. The value is true by default, but can be changed by a filter. The problem is that if I use the site and then then change the filter to be […]