Distinguish between page and post in function

By using post id you can get post type of current post/page. try below code. i have tested and it is working fine for me. add_filter( ‘admin_post_thumbnail_html’, ‘foo’,10,3 ); function foo( $content, $post_id, $thumbnail_id ) { if ( get_post_type( $post_id ) == ‘page’ ) { $content=”<p>foobar</p>” . $content; } else{ $content=”<p>barfoo</p>” . $content; } return … Read more

WordPress add_filter to post_date

You need to add an additional filter on the frontend. Very basically it would look like this: Frontend (eg. single.php): echo apply_filters( ‘my_custom_persian_filter’, $post_date ); Backend (eg. functions.php) function persian_date_function( $date ) { $date = $converted_to_persian; // there you convert date to persian return $date; } add_filter( ‘my_custom_persian_filter’, ‘persian_date_function’ );

Can’t understand apply_filter logic

Thanks for your answers. According to comments above, I modified my code. Now it works. Is it correct way? <?php /* Plugin Name: Test plugin */ $arr = []; add_action( ‘init’, ‘set_var_data’ ); function set_var_data() { global $arr; $arr = [ ‘val’, ‘val2’, ‘val3’ ]; $arr = apply_filters( ‘my_hook’, $arr ); } print_r( $arr );