• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Genesis CPT Archive Settings Field For Posts Per Page

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

  1. Code to create a custom post type named portfolio with single, archive and taxonomy templates for the portfolio CPT.
  2. 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 :

Register for full access

Custom Post Type Meta Box

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.