Tag Info

New answers tagged

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/


1

This question as mentioned in the comments is not related to wordpress by any means. But anywho remove the float on your #portfolio-item and add some flex like its 2015. #contentportfolio { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } ...


1

Woo Commerce is off topic as its a plugin and not specifically related to WordPress but what you can do is copy over the single-product.php template to a WooCommerce folder in your child theme. change the file name and modify the file, then use single_template or template_include with the correct conditional tag. single_template function ...


0

One possibility is to check for the specific product ID at the top of your single-product template and "jump" to another PHP file instead of continuing.


1

You need to check WordPress template-hierarchy how it works. Single Post # The single post template file is used to render a single post. WordPress uses the following path: 1.single-{post-type}.php – First, WordPress looks for a template for the specific post type. For example, post type is product, WordPress would look for single-product.php. ...


1

WordPress has a Template Hierarchy - specifically for taxonomies and terms. So what a template name you want should follow along the lines of: taxonomy-{$taxonomy}-{$term-slug}.php In your case: taxonomy-classifications-cheese.php This will grab onto the cheese category and display this specific template. I'm not entirely sure if this will also catch ...


0

You need get_categories() with an include argument: if (isset($_GET['cat'])) { $this_category = get_categories( array( 'include' => $_GET['cat'] ) ); var_dump($this_category); } You will get an array of stdClass objects containing category data. There are several ways to parse that but this might do: if (isset($_GET['cat'])) { ...



Top 50 recent answers are included