New answers tagged

0

The page_template filter is deprecated now. (http://adambrown.info/p/wp_hooks/hook/page_template) Try using single_template (or archive_template for archive templates) instead. Based on @t31os's answer: // Filter page template add_filter('single_template', 'catch_plugin_template'); // Page template filter callback function catch_plugin_template($template)...


0

Seems like I just need to set has_archive to a string instead of true with the desired slug, in my case archive/dogs. Then, create a page with the dogs slug and set the desired template to it.


0

Check out the hook theme_page_templates, used by the get_page_templates function, filter added since 3.9 updated in 4.4: apply_filters( 'theme_page_templates', $page_templates, $this, $post );


0

Your post type (member_post) doesn't match your template slug (memberPost). Whichever you choose, it must be all lower case.


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

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 ...


0

Put Template name (should be separate name) on page template php file (on toop). like this: <?php /* Template Name: Page Template Name */ ?> your file name can be template-your_template_name.php in theme folder or in subfolder in your theme folder.


0

You can put custom page template in theme: create "templates" folder in theme and put the page. First you check the admin panel and create new page display template name in "Page Attributes", like: If is not, then open archive.php in given this line: <?php /** * The template for displaying Archive pages * * Used to display archive-type pages if ...


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 ...


2

Paging a list of terms/categories/tags are quite easy, and to achieve that, you need minimal info. Lets look at we need the amount of terms the amount of terms per page get_terms() (Just note, the usage of get_terms() have changed in version 4.5). You can also use get_categories() if you wish, get_categories() is just a wrapper function for get_terms() ...


1

I'm not familiar with WP-PageNavi, but I suspect it assumes to be dealing with posts, so it might easily screw up if you use it on a loop like yours. Perhaps the css might still be helpful in styling your html. Anyway, setting up your own pagination is not that difficult. First, you need to know how many categories there are: $cat_amounts=count($cats); ...



Top 50 recent answers are included