{"id":3580,"date":"2019-04-17T04:55:22","date_gmt":"2019-04-17T04:55:22","guid":{"rendered":"https:\/\/docs.contentviewspro.com\/?p=3580"},"modified":"2023-12-27T11:09:01","modified_gmt":"2023-12-27T11:09:01","password":"","slug":"glossary-layout-supports-pagination","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/glossary-layout-supports-pagination\/","title":{"rendered":"Glossary layout supports pagination"},"content":{"rendered":"<p>The default Glossary layout doesn&#8217;t support pagination, that is ineffective when there are a lot of posts in your site.<br \/>\nTo show a <ins>glossary look-alike<\/ins> list, click each index will show relative posts, and support pagination, please follow instructions below:<\/p>\n<ul>\n<li>Step 1: add a custom field to every existing and upcoming posts, to store the glossary index.\n<p>Please add this code to file <strong>functions.php<\/strong> in the theme&#8217;s folder (or install this plugin <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" rel=\"nofollow\">Code Snippets<\/a> then add this code to <a href=\"https:\/\/ps.w.org\/code-snippets\/assets\/screenshot-2.png\" rel=\"nofollow\">the &#8220;Code&#8221; textarea<\/a>):<\/p>\n<pre style=\"font-size:13px\">\n\/\/ Content Views Pro - add custom field glossary heading for each post\nadd_action( 'admin_head', 'cvp_theme_add_ctf_glossary_to_exising_posts' );\nfunction cvp_theme_add_ctf_glossary_to_exising_posts() {\n    if ( !get_option( 'cvp_theme_add_ctf_glossary_index' ) ) {\n        global $wpdb;\n        $wpdb->query( \"INSERT INTO {$wpdb->postmeta} (post_id,meta_key,meta_value)\n  SELECT ID, 'cvp_glossary_filter', LEFT(post_title,1)\n  FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_type = <code style=\" color: red; \">'post'<\/code> AND {$wpdb->posts}.post_status = 'publish'\" );\n        \n        add_option( 'cvp_theme_add_ctf_glossary_index', 1, '', 'no' );\n    }\n}\n\nadd_action( 'save_post', 'cvp_theme_add_ctf_glossary_to_new_posts' );\nfunction cvp_theme_add_ctf_glossary_to_new_posts( $post_id ) {\n    if ( wp_is_post_revision( $post_id ) )\n        return;\n\n    $post_title = get_the_title( $post_id );\n    update_post_meta( $post_id, 'cvp_glossary_filter', mb_substr( $post_title, 0, 1 ) );\n}\n\/\/ End code\n<\/pre>\n<h2>Notice:<\/h2>\n<p>Above code works for the Post type.<br \/>\nTo use for Page type, please replace <code>'post'<\/code> in above code by <code>'page'<\/code>.<br \/>\nTo use for Custom Post type, please replace <code>'post'<\/code> in above code by <strong>Post Type Key<\/strong>, for example: <code>'product'<\/code> or <code>'event'<\/code> depends on your post type.<\/p>\n<\/li>\n<li>Step 2: Create a new View to show the glossary indexes, and allow visitors to filter posts by indexes.<br \/>\nIn Admin area, click Content Views > Add New menu item.<\/p>\n<p>In <strong>Filter Settings<\/strong> tab of the View:<\/p>\n<ul style=\"margin-left:50px\">\n<li>select <code>Custom Fields<\/code> in Advance group, then click <code>Add New<\/code> button. A new field will be added.<\/li>\n<li>select <code>cvp_glossary_filter<\/code> for the &#8220;Field Key&#8221;<\/li>\n<li>select the checkbox: <code>Show as filters to visitors<\/code><\/li>\n<li>select the <code>Button<\/code> option for the Type dropdown\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2019\/04\/Content-Views-Pro-glossary-lookalike.png\" alt=\"\" width=\"788\" height=\"410\" class=\"alignnone size-full wp-image-3669\" srcset=\"https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2019\/04\/Content-Views-Pro-glossary-lookalike.png 788w, https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2019\/04\/Content-Views-Pro-glossary-lookalike-300x156.png 300w, https:\/\/contentviewspro.com\/documentation\/wp-content\/uploads\/2019\/04\/Content-Views-Pro-glossary-lookalike-768x400.png 768w\" sizes=\"auto, (max-width: 788px) 100vw, 788px\" \/><\/p>\n<\/li>\n<\/ul>\n<p>In <strong>Display Settings<\/strong> tab of the View:<\/p>\n<ul style=\"margin-left:50px\">\n<li>Select the <strong>Grid<\/strong> option for Layout. Please do not select the Glossary option, because it doesn&#8217;t support pagination.<\/li>\n<li>Enable pagination<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Then save the View, and add View shortcode to where you want to display it.<\/p>\n<p>Best regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default Glossary layout doesn&#8217;t support pagination, that is ineffective when there are a lot of posts in your site. To show a glossary look-alike 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 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/glossary-layout-supports-pagination\/\"> <span class=\"screen-reader-text\">Glossary layout supports pagination<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"doc_category":[55],"doc_tag":[21],"class_list":["post-3580","docs","type-docs","status-publish","hentry","doc_category-advanced-modification","doc_tag-custom-code"],"year_month":"2026-09","word_count":390,"total_views":"3","reactions":{"happy":"1","normal":"1","sad":"0"},"author_info":{"name":"admin1","author_nicename":"admin1","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/admin1\/"},"doc_category_info":[{"term_name":"Advanced Modification","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/advanced-modification\/"}],"doc_tag_info":[{"term_name":"custom PHP code","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/custom-code\/"}],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=3580"}],"version-history":[{"count":1,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3580\/revisions"}],"predecessor-version":[{"id":5448,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3580\/revisions\/5448"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=3580"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=3580"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=3580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}