Hi Yael,
I would like to display the tags of a details page in a different place other than under the slideshow images.
Please use following code snippet and then use shortcode: [gd_snippet_sc_detail_tags].
/*
* Usage: [gd_snippet_sc_detail_tags]
*/
function gd_snippet_sc_detail_tags( $attr, $content = '' ) {
global $post, $preview;
$html = '';
if ( ! empty( $post ) && ! empty( $post->post_tags ) && ( geodir_is_page( 'detail' ) || geodir_is_page( 'preview' ) ) ) {
$post_tags = trim( $post->post_tags, "," );
$post_tags = explode( ",", $post_tags );
if ( ! empty( $post_tags ) ) {
$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false;
$post_type = $preview && ! $is_backend_preview ? $post->listing_type : $post->post_type;
$post_type_info = get_post_type_object( $post_type );
$post_type_name = __( $post_type_info->labels->singular_name, 'geodirectory' );
$tag_links = array();
foreach ( $post_tags as $post_tag ) {
$post_tag = trim( $post_tag );
$term_exists = term_exists( $post_tag, $post_type . '_tags' );
if ( ! empty( $term_exists ) && ! empty( $term_exists['term_id'] ) ) {
$term = get_term_by( 'id', $term_exists['term_id'], $post_type . '_tags' );
} else {
$term = get_term_by( 'name', $post_tag, $post_type . '_tags' );
}
if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
$tag_links[] = apply_filters( 'geodir_details_taxonomies_tag_link', '<a href="' . esc_attr( get_term_link( $term->term_id, $term->taxonomy ) ) . '">' . $term->name . '</a>', $term );
}
}
if ( ! empty( $tag_links ) ) {
$tag_links = implode( ', ', $tag_links );
$html = wp_sprintf( __( '%s Tags: %s', 'geodirectory' ), $post_type_name, $tag_links );
}
}
}
return $html;
}
add_shortcode( 'gd_snippet_sc_detail_tags', 'gd_snippet_sc_detail_tags' );
Thanks,
Kiran