This code adds a sortable meta box to any custom post type archive.
Here’s a demo showing how the field enables you to set posts per page for the portfolio CPT archive page :
This solution is coded using existing functions which support adding metaboxes in Genesis, therefore, only works in Genesis child themes and contains less code than is normally required to code a metabox in WordPress.
Genesis functions used in this code are :
genesis_cpt_archives_settings_metaboxes
genesis_settings_sanitizer_init
genesis_cpt_archive_settings_defaults
Also uses spl_autoload_register to register the function which loads the PHP class for the metabox.
What’s Included
- Code to create a custom post type named portfolio with single, archive and taxonomy templates for the portfolio CPT.
- Sortable metabox for setting posts per page on CPT archives.
Installation
Once you download the download folder, there’s only 2 steps :
Step 1 : Upload the 2 files named posts_per_page.php & class.Genesis_Posts_Per_Page_Settings.php to your child themes root directory.
Step 2 : Add the following line of code to your child themes functions file :
require_once get_stylesheet_directory() . '/posts_per_page.php';
Register or login to access the download folder :
Was This Tutorial Helpful?