Restrict the_post-navigation to same category?

Customize your posts navigation to get posts in the same tag. the_post_navigation( array( ‘prev_text’ => __( ‘prev chapter: %title’ ), ‘next_text’ => __( ‘next chapter: %title’ ), ‘in_same_term’ => true, ‘taxonomy’ => __( ‘post_tag’ ), ‘screen_reader_text’ => __( ‘Continue Reading’ ), ) ); Source

save_post hook is not called when post is saved

A quick way of debugging the save function before redirection – is to die(print_r($post_id)); // or var_dump($post_id); this will stop all PHP from continuing and is fast for small debugging where you don’t need an entire log. throw that into your function, and see what happens in it – change the variable to see if … Read more

Get the amount of posts on a current page

You can use the below to output the post amounts <?php $args = array( ‘post_type’ => ‘post’, ‘showposts’ => ’10’ ); $wp_query = new WP_Query($args); // amount of posts per on the page $post_number = $wp_query->post_count; // amount of posts across the post pages $post_number2 = $wp_query->found_posts; echo $post_number.'<br />’; echo $post_number2.'<br />’; while ( … Read more

Add a variable in a post

One option would be to set up a shortcode. You can add this either in your theme’s functions.php, or as a plugin: add_shortcode(‘varnumber’, ‘my_var_number’); function my_var_number($atts, $content = null) { return ‘Put whatever number you want here instead of this text’; } Wherever you want the number to appear, use the shortcode [varnumber] in the … Read more

Second get_permalink inside loop points to wrong URL

get_permalink doesn’t output anything, it returns the permalink. Your first call works because you use it within the_title, which echos its value along with any before and after parameters you pass to it. Change your second instance to: <?php echo get_permalink(); ?> or use the_permalink, which echos the value instead of returning. <?php the_permalink(); ?> … Read more