Home › Forums › WoodMart support forum › Category description under product list
Category description under product list
- This topic has 3 replies, 2 voices, and was last updated 3 years, 3 months ago by
Elise Noromit.
-
AuthorPosts
-
February 3, 2022 at 10:35 am #349859
CoralFagorParticipantHello,
We were planning in putting content on category page for SEO purpose but didn’t want to put text first becouse it would push products down.
We found code that enables it on most themes, but it doesnt seem to work in this case, with Woodmart. It kinda works, but it takes description of last product in product list. Can you please tell us how we can achive this?Best regards,
Coral Srbija.Code is under:
// Add term page
add_action( ‘product_cat_add_form_fields’, ‘wpm_taxonomy_add_new_meta_field’, 10, 2 );function wpm_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class=”form-field”>
<label for=”term_meta[custom_term_meta]”><?php _e( ‘Details’, ‘wpm’ ); ?></label>
<textarea name=”term_meta[custom_term_meta]” id=”term_meta[custom_term_meta]” rows=”5″ cols=”40″></textarea>
<p class=”description”><?php _e( ‘Detailed category info to appear below the product list’,’wpm’ ); ?></p>
</div>
<?php
}// Edit term page
add_action( ‘product_cat_edit_form_fields’, ‘wpm_taxonomy_edit_meta_field’, 10, 2 );function wpm_taxonomy_edit_meta_field($term) {
// put the term ID into a variable
$t_id = $term->term_id;// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option( “taxonomy_$t_id” );
$content = $term_meta[‘custom_term_meta’] ? wp_kses_post( $term_meta[‘custom_term_meta’] ) : ”;
$settings = array( ‘textarea_name’ => ‘term_meta[custom_term_meta]’ );
?>
<tr class=”form-field”>
<th scope=”row” valign=”top”><label for=”term_meta[custom_term_meta]”><?php _e( ‘Details’, ‘wpm’ ); ?></label></th>
<td>
<?php wp_editor( $content, ‘product_cat_details’, $settings ); ?>
<p class=”description”><?php _e( ‘Detailed category info to appear below the product list’,’wpm’ ); ?></p>
</td>
</tr>
<?php
}// Save extra taxonomy fields callback function
add_action( ‘edited_product_cat’, ‘save_taxonomy_custom_meta’, 10, 2 );
add_action( ‘create_product_cat’, ‘save_taxonomy_custom_meta’, 10, 2 );function save_taxonomy_custom_meta( $term_id ) {
if ( isset( $_POST[‘term_meta’] ) ) {
$t_id = $term_id;
$term_meta = get_option( “taxonomy_$t_id” );
$cat_keys = array_keys( $_POST[‘term_meta’] );
foreach ( $cat_keys as $key ) {
if ( isset ( $_POST[‘term_meta’][$key] ) ) {
$term_meta[$key] = wp_kses_post( stripslashes($_POST[‘term_meta’][$key]) );
}
}
// Save the option array.
update_option( “taxonomy_$t_id”, $term_meta );
}
}
// Display details on product category archive pages
add_action( ‘woocommerce_after_shop_loop’, ‘wpm_product_cat_archive_add_meta’ );function wpm_product_cat_archive_add_meta() {
$t_id = get_queried_object()->term_id;
$term_meta = get_option( “taxonomy_$t_id” );
$term_meta_content = $term_meta[‘custom_term_meta’];
if ( $term_meta_content != ” ) {
echo ‘<div class=”woo-sc-box normal rounded full”>’;
echo apply_filters( ‘the_content’, $term_meta_content );
echo ‘</div>’;
}
}February 3, 2022 at 11:08 pm #350002
Elise NoromitMemberHello,
You do not need any code. Please remove it. You can find the option to put the description below the product grid in the Theme Settings > Product Archives: https://gyazo.com/cf9f32f27dd0b47ff8bf537eb43baba3
If you have any questions please feel free to contact us.
Best Regards
February 4, 2022 at 7:12 am #350070
CoralFagorParticipantHello Elise,
Thank you very much for this information. We must have overlooked it somehow.
Best regards,
Coral Srbija.February 4, 2022 at 11:16 am #350142
Elise NoromitMemberYou are welcome! We are here to help.
Wish you a wonderful day!
-
AuthorPosts
The topic ‘Category description under product list’ is closed to new replies.
- You must be logged in to create new topics. Login / Register