Tag Info

New answers tagged

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

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


0

... from a custom Wordpress page template to my child theme functions.php file... You can't. And a global variable won't help. The theme's functions.php file loads first, before any other templates load. You can't pass variables backwards to something that has already loaded. What I think you want to do, based on what your code appears to be trying ...


0

Try this : https://wordpress.org/plugins/display-template-name/ It's my plugin. It display the current template file + other include files within the current


0

Ok, an answer to all. First, thank you for you help. Anyway, none of your solutions really address my issue. I don't like custom links on nav menus, at all. And that's because they're not dynamic, you cannot build them dynamically. So when you move the site and change url (for example, from staging to production) you'll have to remember to manually change ...


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


0

Just create an archive-{post_type}.php when you create a custom post type and include this function: flush_rewrite_rules(); Make a page of your custom post type. It's called an archive page.


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


0

Yes, the function is_post_type_archive only works in archive.php To have an item on nav menu links to your staff_member, you will add a custom link menu item in stead of a page whose template is your file tempate. The URL of that item will be got when you vardump this: get_post_type_archive_link('staff_member') And to custom the performance of the ...


-1

First create on page named as Items as your wish which display the content from items post types, than create one template file as below and named that template-items. Select that template for the page you have created. <div class="container"> <div class="row"> <div class="col-md-9"> <div class="panel ...


0

The simplest solution: echo get_the_category_list( ', ' ); Following your way: Change your $args like so: $args = array( 'template' => '%2$l', 'term_template' => '%2$s', ); And then, add this to your functions.php file (this will affect all %l markers!); add_filter( 'wp_sprintf_l', function($templates) { // ...


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


0

You have a few issues here The following piece of code is wrong and unnecessary $category = get_post(); $category = $category->post_title; The current page object is saved in get_queried_object(), so you can use this function to get your post title. Also, post_title is not the correct property to use here. You want to look at the post slug which is ...


0

Based on the code you've shown, the main problem is this: bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/rebons' ) ); Should be this: bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); The way you are adding the nav tabs may also be a problem. Here is a gist that might help. ...


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


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


0

You misunderstand what page_template does. It does not create a new template that you will "show up" somewhere and that you can use. It replaces the page.php template provided by the theme. I think that what you want is template_redirect: function custom_page_template( $page_template ) { if (is_home()) { get_header(); echo 'do stuff'; ...



Top 50 recent answers are included