get_next_post() not working

Only a guess but you might need global $post before your code. According to the Codex docs for the functions you are using the return values are Null if global $post is not set. Also you might want to use their suggested logicals: if (!empty( $prev_post ))

Creating a Post, can authors be ordered by last name?

Here’s one example how we can modify the order of users in the dropdowns on the post.php and post-new.php pages (PHP 5.4+): /** * wp_dropdown_users – modify ordering on post.php and post-new.php */ add_filter( ‘wp_dropdown_users_args’, function( Array $query_args, Array $args ) { // Nothing to do if we’re not on post.php and post-new.php if( ! … Read more

Count number of published posts by type

If you prefer the $wpdb direct queries you can use something like this: global $wpdb; $count = $wpdb->get_var( “SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type=”code” and post_status=”publish”” ); echo $count; In the sql query above change the post_type to whatever you like. This will return count of published posts under specific post type only. If you … Read more

Insert posts in two tables

No. You’d have to change core WordPress functionality to achieve that (lots of work, and you’ll have to do it again for each upgrade). And if you’re finished with that, you’ll probably have to change some plugins as well. Generally, a big wp_posts table isn’t a problem. If your site is slow, look into where … Read more

Use template for posts with a particular category grandparent

Let me update your code 🙂 You don’t need to select grandparent category for your post. First we need to get grandparent category name. Here is the function; function get_grandparents_category_salgur( $id) { $parent = get_term( $id, ‘category’ ); if ( is_wp_error( $parent ) ) return $parent; if ( $parent->parent && ( $parent->parent != $parent->term_id ) … Read more

Fatal error post.php help :(

Put your code in whatever function: function whatever(){ // do stuff } add_action( ‘init’, ‘whatever’ ); Or use this to check whether user is logged in or not: if( get_current_user_id() ) { // logged in user }