How to get a current post’s blog id

Here’s a quick way you could do it, though there are quite likely easier/better ways to do it. This is just what I can think of at the moment. Add a quick function to functions.php that will store the blog ID in the post meta. Then when you need to check where the post came … Read more

get_previous_post in same categories

get_previous_post uses get_adjacent_post() which has a bunch of filter hooks you can use but a much simpler approach would be to create your own function, something like this: // Create a new filtering function that will add our where clause to the query function date_filter_where( $where=”” ) { global $post; $where .= ” AND post_date … Read more

database collation differences

From quick check of the MySQL manual the database collation is only relevant for database–level operations (emphasis mine): For CREATE TABLE statements, the database character set and collation are used as default values for table definitions if the table character set and collation are not specified. To override this, provide explicit CHARACTER SET and COLLATE … Read more

How to reference a function from a class in a different file which is also namespaced?

Firstly, to do this the register_metaboxes() method needs to be static: public static function register_metaboxes() { } Then, for the callback you pass an array with the full class name including the namespace: $args = array( ‘register_meta_box_cb’ => [ ‘FrameWork\Helper\Metabox’, ‘register_metaboxes’ ], ); If, for whatever reason, register_metaboxes() isn’t static (i.e. you’re using $this) then … Read more