Tag Info

New answers tagged

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


0

Tried your code and its perfect but the changes you are trying to make needs to be added to a correct file. For your code to work you need to place it in your current theme's functions.php add_action( 'woocommerce_before_checkout_form', 'add_checkout_notice', 11 ); function add_checkout_notice() { wc_print_notice( __( 'A notice message instead.', ...


0

You will need to learn the very basics of how Wordpress works and how templates interact to display content. Your question is rather broad looking at your actual problem. In short, a basic template should look like this <php get_header(); if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'content' ); } ...


0

I don't really know what you mean by "using the Wordpress API in a site as opposed to making it a theme" but I am assuming you mean something like "use the backend but not the front facing stuff". So, given that, yes you can, but a lot of things will not work. There are too many hooks in the WordPress core-- 'pre_get_posts' for example-- and that are ...


2

You can do that with single_template filter. First you will need to check if a post belongs to a top level category. So here is the function. // custom single template for specific category function wpse_custom_category_single_template( $single_template ) { global $post; // get all categories of current post $categories = get_the_category( ...


3

EDIT NOTE If you need only the parent and first level child terms, the answer from @Roberthue should work great. If you need all level child terms, then my solution should work) I have updated my code to be more effecient. Run get_ancestors() only if we cannot find the parent term or its direct children Stop the execution of the foreach loop ...


0

Just in case someone reads this after all this time (2011): I ran into the same issue, and after reading many posts, get back to my WP, and 'voila !' : It was working as expected ! this is a cache issue IMHO (WP 4.2.2). Cheers.


0

Here's what works for me: add_filter('single_template', function($original){ global $post; $post_name = $post->post_name; $post_type = $post->post_type; $base_name = 'single-' . $post_type . '-' . $post_name . '.php'; $template = locate_template($base_name); if ($template && ! empty($template)) return $template; return ...


1

According to WordPress template hierarchy, the page templates will fall back to page.php of the new (active) theme. You can read more about template hierarchy here:- https://developer.wordpress.org/themes/basics/template-hierarchy/



Top 50 recent answers are included