Support » Fixing WordPress » article page number

  • Martin

    (@astronaut123)


    Is there any chance to get on a single article page the page number where the article is paged on the overview.

    I want to have a kind of breadcrumb (on the single page!) like this:

    Home >> Page 5 >> Lorem ipsum

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try to get the number with this:

    <?php
    global $wpdb, $post;
    
    $query = "
        SELECT COUNT('ID') as count FROM $wpdb->posts p
        WHERE p.post_type = %s AND p.post_date >= %s  AND p.post_status = 'publish'
        ORDER BY p.post_date DESC";
    
    $query = $wpdb->prepare( $query, $post->post_type, $post->post_date );
    $count = $wpdb->get_var( $query );
    
    if ( $count ) {
    	echo 'Page ' . $count;
    }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘article page number’ is closed to new replies.