Tag Info

Hot answers tagged

3

You can approach this by first using a database query to count the number of pages that are already using the template: $query = "SELECT COUNT(*) as total FROM prefix_posts as p JOIN prefix_postmeta as m ON p.ID = m.post_id WHERE p.'post_type' = 'page' AND p.'post_status' = 'publish' AND m.'meta_key' = '_wp_page_template' AND ...


2

Custom post type archive page does not need "dumb" Page. In fact, there could be the culprit. You should try this: Remove /* Template Name: Staff */ from archive-staff_member.php (not needed) Remove "dumb" stuff Page (if created). There could be some permalink conflict. Go to Admin > Settings > Permalinks and re-save it (it will regenerate rewrite rules) ...


1

Update You can make use of the add_rewrite_endpoint: add_rewrite_endpoint( 'schools', EP_PERMALINK | EP_PAGES ); You can then check in the sidebar for the schools variable: global $wp_query; if ( isset( $wp_query->query_vars['schools'] ) ) { // ... } What is worth mentioning is that your URL will look like ...


1

Simple solution, use get_template_part(). For example: get_template_part( 'partials/footer' ); Which would get the footer.php inside the partials/ directory. Another example: get_template_part( 'partials/footer', 'home' ); Which would get the footer-home.php inside the partials/ directory. One more example: get_template_part( ...


1

On request, a custom template does not mean custom query :-). As already mentioned, NEVER use query_posts, it breaks the main query object and page functionality, one of which is pagination. Many plugins and functions relies on the main query object, you break that, you break those functions as well. As this is a custom category template, it is also not ...


1

I assume you would like to end up with something like this: Theme way If you want to put this logic in your template, as you state in your question, there is quite a bit of coding. You need to: create metabox create content (field and description) in that metabox - that's called "callback" in the meta_box docs create logic that saves data from the ...


1

The template for the page is called page.php and should be in the same theme folder as index.php (alternatively you can use the is_page() function to do a template inside index.php but it's more difficult and there's little point to that). Best way forward is to study an existing theme and figure how things work. A look at the template hierarchy should help ...



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