Glossary layout supports pagination

The default Glossary layout doesn’t support pagination, that is ineffective when there are a lot of posts in your site.
To show a glossary lookalike list, click each index will show relative posts, and support pagination, please follow instructions below:

  • Step 1: add a custom field to every existing and upcoming posts, to store the glossary index.

    Please add this code to file functions.php in the theme’s folder (or install this plugin Code Snippets then add this code to the “Code” textarea):

    // Content Views Pro - add custom field glossary heading for each post
    add_action( 'admin_head', 'cvp_theme_add_ctf_glossary_to_exising_posts' );
    function cvp_theme_add_ctf_glossary_to_exising_posts() {
        if ( !get_option( 'cvp_theme_add_ctf_glossary_index' ) ) {
            global $wpdb;
            $wpdb->query( "INSERT INTO {$wpdb->postmeta} (post_id,meta_key,meta_value)
      SELECT ID, 'cvp_glossary_filter', LEFT(post_title,1)
      FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_type = 'post' AND {$wpdb->posts}.post_status = 'publish'" );
            
            add_option( 'cvp_theme_add_ctf_glossary_index', 1, '', 'no' );
        }
    }
    
    add_action( 'save_post', 'cvp_theme_add_ctf_glossary_to_new_posts' );
    function cvp_theme_add_ctf_glossary_to_new_posts( $post_id ) {
        if ( wp_is_post_revision( $post_id ) )
            return;
    
        $post_title = get_the_title( $post_id );
        update_post_meta( $post_id, 'cvp_glossary_filter', substr( $post_title, 0, 1 ) );
    }
    // End code
    
  • Step 2: Create a new View to show the glossary indexes, and allow visitors to filter posts by indexes.
    In Admin area, click Content Views > Add New menu item. In Filter Settings tab of the View, select Custom Fields in Advance group, then click Add New button.
    A new field will be added, please select cvp_glossary_filter for the “Field Key”, then select the checkbox: Show as filters to visitors

Then save the View, and add View shortcode to where you want to display the glossary.

Best regards,