/** * Sets up needed actions/filters. * * @since 1.0.0 */ public function __construct() { $this->templates = array(); // Set posts per archive team page add_action('pre_get_posts', array($this, 'set_posts_per_archive_page')); // Add a filter to the page attributes metabox to inject our template into the page template cache. add_filter('page_attributes_dropdown_pages_args', array($this, 'register_templates')); // Add a filter to the save post in order to inject out template into the page cache. add_filter('wp_insert_post_data', array($this, 'register_templates')); // Add a filter to the template include in order to determine if the page has our template assigned and return it's path. add_filter('template_include', array($this, 'view_template')); // Add a filter to load a custom template for a given post. add_filter('single_template', array($this, 'get_single_template')); // Add your templates to this array. $this->templates = array('template-team.php' => __('Team Page', 'cherry-team')); // Adding support for theme templates to be merged and shown in dropdown. $templates = wp_get_theme()->get_page_templates(); $templates = array_merge($templates, $this->templates); /** * Filter posts per archive paghe value * @var int */ self::$posts_per_archive_page = apply_filters('cherry_team_posts_per_archive_page', self::$posts_per_archive_page); }
/** * Get number of posts per archive page * * @since 1.0.5 * @return int */ public static function get_posts_per_archive_page() { if (null !== self::$posts_per_archive_page) { self::$posts_per_archive_page; } /** * Filter posts per archive page value * @var int */ self::$posts_per_archive_page = apply_filters('cherry_team_posts_per_archive_page', 6); return self::$posts_per_archive_page; }