Add the .html extension to custom post types

Lets take these functions and paraphrase them into english, then put them in the order they’re ran. I’m going to deliberately avoid using PHP in this answer, but a basic understanding of PHP will be necessary: When the `post_type_link` filter runs: // the add_action calls run: `wpa_course_post_link` as it has priority 3 // function wpa_course_post_link(…. … Read more

Get product attribute for Simple product in WooCommerce

Building on Loic’s answer for an attribute of pa_manufacturer: if ( get_post_type( $post ) === ‘product’ && ! is_a($product, ‘WC_Product’) ) { $product = wc_get_product( get_the_id() ); // Get the WC_Product Object } $product_attributes = $product->get_attributes(); // Get the product attributes // Output $manufacturer_id = $product_attributes[‘pa_manufacturer’][‘options’][‘0’]; // returns the ID of the term $manufacturer_name = … Read more

Add Category Name to REST API

The API responses are designed to only return the IDs. You can then fetch the full information for each term. Of course it would not be very performant to make dozens of requests. So instead, the REST API has the concept of embedding resources. If you make your request, but include _embed=1 in your URL, … Read more

Using a different template per Custom Taxonomies for single term archive pages

I would intercept the template loader at template_redirect: function wpse53892_taxonomy_template_redirect() { // code goes here } add_action( ‘template_redirect’, ‘wpse53892_taxonomy_template_redirect’ ); Then, you would check to see if the query is a custom taxonomy: if ( is_tax() ) { // This query is a custom taxonomy } Next, get the term object, and find out if … Read more