how to add_filter to non hook function

Assuming that this– add_filter( ‘kandombe_theme_thumb’, ‘kandombe_lazy_loads’);— is the line/hook you are talking about. You don’t hook to functions. That is not how it works. Hooks have to be intentionally created with apply_filters or do_action. Your code would have to be written like this for that to work: function kandombe_theme_thumb($id, $width, $height, $align=”) { //some code … Read more

Same post appears in related Posts?

Aahhh, it’s a typo, I guess. There is no parameter called posts__not_in. It’s called post__not_in. So you should change your code to: function dark_delight_get_related_posts(){ $post = get_post(); $args = array( ‘posts_per_page’ => 4, ‘ignore_sticky_posts’ => true, ‘post__not_in’ => array($post->ID), // post and not posts ); $categories = get_the_category(); if( !empty($categories) ){ $category = array_shift( $categories … Read more

Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?

Use wp_enqueue_script. You assign a name to your js file when enqueued, and it will stop a file from being enqueued multiple times. Right now your JS is simple enough, but as it gets more complex, it’s better to have it outside in it’s on .js file. add_action( ‘wp_enqueue_scripts’, ‘add_my_js’ ); function add_my_js() { wp_enqueue_script( … Read more

WordPress show bad the php hour and date

Did you go to Settings >> General and set the correct offset for your timezone? To get the date: <?php $date = get_the_time(‘dmY’, $post->ID); ?> To print the date: <?php the_date(‘dmY’); ?> Both need to be within the Loop!