Forum Replies Created
-
AuthorPosts
-
Cris
ParticipantPerfect!! I have learned a lot with this. Thanks a lot Tom!!!
I have proven that without ‘ . $term->slug . ‘ it also works.
Cris
ParticipantPerfect!!! Thanks a lot Tom !!
Cris
ParticipantHi Tom, somebody told me that get_the_terms() retrieves the terms of the taxonomy that are attached to the post, but I can’t make it work. To make it works with WPSP, what should I change and where do I add the names of the taxonomies?
function get_the_terms( $post, $taxonomy ) { $post = get_post( $post ); if ( ! $post ) { return false; } $terms = get_object_term_cache( $post->ID, $taxonomy ); if ( false === $terms ) { $terms = wp_get_object_terms( $post->ID, $taxonomy ); if ( ! is_wp_error( $terms ) ) { $term_ids = wp_list_pluck( $terms, 'term_id' ); wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' ); } } /** * Filters the list of terms attached to the given post. * * @since 3.1.0 * * @param WP_Term[]|WP_Error $terms Array of attached terms, or WP_Error on failure. * @param int $post_id Post ID. * @param string $taxonomy Name of the taxonomy. */ $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy ); if ( empty( $terms ) ) { return false; } return $terms; }
Cris
ParticipantKeep showing all the taxonomy data, instead of showing the one that corresponds to each entry.
You can see it here
the first one on the left should show only the value 0, and the others the value 3 and 4 respectively. But all the taxonomy values (0, 1, 2, 3, 4) appear in each of the entries.Cris
ParticipantThat code doesn’t work properly, Tom. I explain:
Within the “dormitorio” taxonomy I have the values 0, 1, 2, 3 and 4 (these are the room numbers). If an entry has only the value 3 marked, only that value should be shown but it does not do well because it shows all the values 0, 1, 2, 3 and 4. How can it be solved and how can include several taxonomies with diferents classes in this code?
$terms = get_terms( ( array('taxonomy' => 'dormitorio', 'hide_empty' => false,))); if ( isset( $terms ) && '' !== $terms ) { foreach( $terms as $term ) { echo '<div class="tax dormitorio">'; echo $term->name; echo '</div>'; }
Cris
ParticipantI have created a type of personalized entrance with several taxonomies as categories (dormitorios, tipo, zona…). When using WPSP, it shows each personalized entry with its categories. The code you provided to show the categories shows all the fields created in that category, instead of showing the specific data of that entry. Look at the attached images:
You can see it live here
Cris
ParticipantThanks Tom!
I tried it and it shows all the data in the taxonomy, instead of showing the specific data that corresponds to each entry.$terms = get_terms( ( array('taxonomy' => 'dormitorio', 'hide_empty' => false,))); if ( isset( $terms ) && '' !== $terms ) { foreach( $terms as $term ) { echo '<div class="tax dormitorio">'; echo $term->name; echo '</div>'; }
Cris
ParticipantThanks Tom, your code to add class works fine.
I hope you don’t laugh at me but I’m not a developer:) I did this and only the word “Array” returns to me.
$terms = get_terms( ( array('taxonomy' => 'post_tag', 'hide_empty' => false,))); if ( isset( $terms ) && '' !== $terms ) { echo '<div class="tax referencia">'; echo $terms; echo '</div>'; }
Can you help me with taxonomies, please?
Cris
ParticipantSorry, another thing.
How can I customize the “custom fields” using css? I don’t know how to add classes or a icon image.I explain, because maybe I can’t do what I want:
I am doing a real estate website and I want to use WPSP to display them on the home page. I would like to put below the photo, the characteristics (bedrooms, bathrooms, price, etc …).
With the code you give, the custom fields appear pasted behind each other and I would like to add an icon or text in front of them. I also have some taxonomies that I want to place next to the custom fields.
You can see what I am doing here.
In addition to custom fields I am using taxonomies to be able to search with the Search & Filter pluginThanks!
Cris
ParticipantHi
I used this code for the custom field “precio” and it works correctly:
add_action( ‘wpsp_before_content’,’wpsp_add_custom_meta’);
function wpsp_add_custom_meta()
{
$meta = get_post_meta( get_the_ID(), ‘precio’, true );
if ( isset( $meta ) && ” !== $meta )
echo $meta; echo “€”;
}I want to do the same with 2 taxonomies (similar to categories), not custom fields, but that code does not work with them.
Cris
ParticipantHi Tom,
Your code works well with custom field but I also need to do the same with several taxonomies. How would it be done?
ThanksCris
ParticipantSorry Tom
I set it wrong. Now it is solved.
I’m sorry.Cris
ParticipantI just realized that in the adaptive design view of Firefox, for developers, I do see the dots of the carousel. The dots disappears on the big screen. The same thing happens in Chrome.
Cris
ParticipantIt still doesn’t work properly because they don’t behave like a carousel. The images should rotate and the dots appear below.
Cris
ParticipantI deactivated Autoptimize and it is still not functional
-
AuthorPosts