Loading custom page template via plugin

To add custom template in page attributes template section you have to first add your template to dropdown and load it in template_include hook when current page has selected it as current template. /** * Add “Custom” template to page attirbute template section. */ function wpse_288589_add_template_to_select( $post_templates, $wp_theme, $post, $post_type ) { // Add custom … Read more

Add custom field to the archive page?

Using the Advanced Custom Fields plugin you can assign options pages to you custom posttype like this: if( function_exists(‘acf_add_options_page’) ) { acf_add_options_page(array( ‘page_title’ => ‘YOUR_PAGE_TILE Options’, ‘menu_title’ => ‘YOUR_MENU_TITLE Options’, ‘menu_slug’ => ‘options_YOUR_SLUG’, ‘capability’ => ‘edit_posts’, ‘parent_slug’ => ‘edit.php?post_type=YOUR_CUSTOM_POSTTYPE_SLUG’, ‘position’ => false, ‘icon_url’ => ‘dashicons-images-alt2’, ‘redirect’ => false, )); } That way you get an … Read more

How to get the custom post type from an archive page?

There are a several of ways to do this. Put: var_dump($wp_query->query,get_queried_object()); die; In your archive.php and you should see two of those ways. $wp_query->query will have post_type component for custom post types. That will not be there for post post types. get_queried_object will return quite a bit of data for custom post types but null … Read more