Hopefully an easy fix for someone!
I have a custom post type, named 'products'.
Using this code, I am getting the name of each 'product':
Each of these products is inside a category. What I want to do is get not only the_title, but get the category.
I tried using
but no luck.
Anyone got any clue?
EDIT:
Sorry, I have these created inside my products custom post type.
which give me external and internal products as categories. But inside these, I have categories which have been made on the wordpress backend.
This is how it looks when I select a product:
<img src=" " alt="backend">
I have a custom post type, named 'products'.
Using this code, I am getting the name of each 'product':
Code:
<?php
//Define your custom post type name in the arguments
$args = array('post_type' => 'products');
//Define the loop based on arguments
$loop = new WP_Query( $args );
//Display the contents
while ( $loop->have_posts() ) : $loop->the_post();
?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php endwhile;?>
Each of these products is inside a category. What I want to do is get not only the_title, but get the category.
I tried using
Code:
<?php the_category(); ?>
Anyone got any clue?
EDIT:
Sorry, I have these created inside my products custom post type.
Code:
add_action( 'init', 'create_product_cat_external' );
function create_product_cat_external() {
register_taxonomy(
'ExternalProducts',
'products',
array(
'label' => __( 'External Products' ),
'rewrite' => array( 'slug' => 'externalproducts' ),
'hierarchical' => true,
)
);
}
add_action( 'init', 'create_product_cat_internal' );
function create_product_cat_internal() {
register_taxonomy(
'InternalProducts',
'products',
array(
'label' => __( 'Internal Products' ),
'rewrite' => array( 'slug' => 'internalproducts' ),
'hierarchical' => true,
)
);
}
which give me external and internal products as categories. But inside these, I have categories which have been made on the wordpress backend.
This is how it looks when I select a product:
<img src=" " alt="backend">