add_action not using ‘delete_post’ action with wp_delete_post

You need to use before_delete_post action. As its already very late when delete_post action is run. WordPress un-attach all the attachments before running delete_post action. So when you run get_posts in your delete_attachment function there are no attachments found. So you need to hook your function to before_delete_post. add_action(‘before_delete_post’,’abc_delete_attachment’);

The ‘https_local_ssl_verify’ filter

The apply_filters() function lets plugins and themes override the value. So yes, you could manually set sslverify to false. The code snippet you included will set it to false in the absence of any filter. Let’s say I have a plugin that wants to force it to true. I would add this: add_filter( ‘https_local_ssl_verify’, ‘__return_true’ … Read more

Get post excerpt and title by specific post ID?

Your get_excerpt() function uses the global $post variable, which is out of scope inside your function. // Changing excerpt length function get_excerpt($count){ $permalink = get_permalink($post->ID); $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, $count); $excerpt = substr($excerpt, 0, strripos($excerpt, ” “)); $excerpt = $excerpt.’… <a href=”‘.$permalink.'”>Read More</a>’; return $excerpt; } That means that … Read more

How would I get 1 latest post from a query for 5 posts?

You can use $current_post property of WP_Query $query_args = array( “posts_per_page” => “5” ); $listedPosts = new WP_Query($query_args); // the loop if ( $listedPosts->have_posts() ) { while ( $listedPosts->have_posts() ) { $listedPosts->the_post(); if ( (int) $listedPosts->current_post === 0 ) { // loop content for hero post } else { // loop content for remaining posts … Read more

Sorting posts according to view counts not working

Your code doesn’t make sense. You use query_posts(), which you should never do, but all that does is clobber the main query. You don’t use the clobbered query though. You then use get_posts() with an undefined (so far as code posted indicates) argument list, so it is not going to return what you expect. I … Read more

Remove arrows from previous and next link

You should have to look at what the codex says about previous_post_link( $format, $link, $in_same_term = false, $excluded_terms=””, $taxonomy = ‘category’ ) and next_post_link( $format, $link, $in_same_term = false, $excluded_terms=””, $taxonomy = ‘category’ ) Both have the same parameters, the first parameter $format is the important one to have a look at here Format string … Read more

Remove Shortcode […] from Blog Preview

You can do with PHP. Just remove part where is get_content() and add this: <?php $content=get_the_content(); $content = preg_replace(‘#\[[^\]]+\]#’, ”,$content); echo apply_filters(‘the_content’, $content); ?> That is regular expression added inside content. This regex will remove all tags inside content.

Sorting posts according to the term they belong to

I’m not going to discuss implementation of a slider, that is too broad. There are a couple of tutorials around which you can look at on how to implement simple sliders The real issue here is the query itself. Sorting a query by the terms a post belongs to is quite heavy operations, and if … Read more