How to overwrite / extent wordpress function is_email

is_email is a native WP function. As you can see here (https://core.trac.wordpress.org/browser/tags/5.0.3/src/wp-includes/formatting.php#L2886) it allows you to modify it with filter is_email. So yes – anytime the function is_email will be called, it will run, and at the end it will run your filters allowing you to modify the result. But… The filter should take 3 … Read more

Can I hide certain upload folders in media library [duplicate]

Perhaps a bit quick and dirty, but this should work: function media_library_hide_dlm_downloads($where) { if(isset($_POST[‘action’]) && ( $_POST[‘action’] == ‘query-attachments’)) { $where .= ‘ AND guid NOT LIKE “%wp-content/uploads/dlm_downloads%”‘; } return $where; } add_filter(‘posts_where’, ‘media_library_hide_dlm_downloads’); Read more about the posts_where filter.

Execute function after a post has been published

function check_meta( $post_id, $post, $update ) { $post_type = get_post_type($post_id); if ( “post” != $post_type ) return; $video_code_val = get_post_meta( $post_id, ‘video_code’, true ); // Check if the video_code field has a value. if ( ! empty( $video_code_val ) ){ //if it does, set post format set_post_format( $post_id, ‘video’ ); } } add_action( ‘save_post’, ‘check_meta’, … Read more

Setting custom canonical urls

It depends on how your canonical URLs are being written to the page. In your theme’s header you may find something like: <link rel=”canonical” href=”https://wordpress.stackexchange.com/questions/331598/<?php echo get_permalink(); ?>”> If you are able to edit your theme (or child theme if using a distributed theme) you can put whatever you want there instead. For instance, you … Read more

Dropdown menu on custom page with product to choose number of products per page

Maybe this would work? function ps_pre_get_products_query( $query ) { $per_page = filter_input(INPUT_GET, ‘perpage’, FILTER_SANITIZE_NUMBER_INT); if ( ! is_admin() && is_woocommerce() && is_page() ) { $query->set( ‘posts_per_page’, $per_page ); } } I tested your code and the if statement didn’t seem to work with is_page() (but that could also be because my local WP sandbox is … Read more

Auto delete post if certain custom field data is empty

kses_remove_filters(); $new_id = wp_insert_post($post_arr, true); kses_init_filters(); if (is_wp_error($new_id)) { $this->write_log(“error occurred in wordpress post entry: ” . $new_id->get_error_message() . ” ” . $new_id->get_error_code(), true); return; } if($url) update_post_meta($new_id, ‘source_link’, $url); else { // wp_delete_post($new_id); // Move post to trash $deleted = wp_delete_post($new_id, true); // Permanently delete post if(! $deleted ){ $this->write_log(“error deleting post entry.”, true); … Read more

Ajax posts filter by date, comments, top views, top likes

I haven’t tested the code, but this should help. option elements do not have a name attribute: <option name=”top-views” value=”top-views”>Top Views</option> <option name=”top-likes” value=”top-likes”>Top Likes</option> And therefore $_POST[‘top-views’] for example, is not going to be set, or that the value is not the top-views in the above option. Use the proper option markup Based on … Read more