Hot answers tagged

2

File should be single-member_post.php instead of single-memberPost.php. In single-{posttype} , {post_type} is the $post_type argument of the register_post_type() function. Never use flush_rewrite_rules(); in init use it only on theme/plugin deactivate or activate. Since this is a theme you can use it on after_switch_theme hook. add_action( 'init', '...


1

I think that this native function will help you: if ( is_single() ) { //do stuff } You will find more information in the WP developers section. It works for any post type, except attachments and pages.


1

Where to put custom page templates in theme? Custom page templates in page-templates folder are automatically recognized by WordPress.This folder is recommended for global or multi-purpose page-templates. You can check more organizing theme files on theme development handbook. but it does not work with my theme? Are you sure you have template files ...


1

I wonder if you mean to register a file-less template with the theme_page_templates filter like this: /** * Add a file-less page template to the page template dropdown */ add_filter( 'theme_page_templates', function( $page_templates, $wp_theme, $post ) { // Edit this to your needs $fileless_theme_slug = 'my_fileless_page_template'; $...


1

I still run into the desire to do this kind of thing and have settled on the following solution which I proposed in the OP and like for a couple reasons: It's very transparent and feels consistent with keeping the logic in the theme. It makes it very easy to customize a template later if needed. Custom Template Here's the entire template file if I don't ...



Only top voted, non community-wiki answers of a minimum length are eligible