Tagged: custom taxonomies
-
AuthorPosts
-
June 21, 2021 at 2:59 am #1306630
Hello,
In continuation of this ticket: https://kriesi.at/support/topic/custom-post-archive/
I was given the below code to display custom taxonomies on postslider.php, problem is i don’t want to display all taxonomies. For example i want to display ‘brand’, ‘condition’, ‘size’ etc, but I don’t want to display the ‘Show Ads’ taxonomy since i use it purely for administration purposes. Is there a way i can add a filter to remove one or two particular taxonomies?
$taxonomies = get_object_taxonomies( get_post_type( $the_id ) );
$cats = ”;
$excluded_taxonomies = array_merge( get_taxonomies( array( ‘public’ => false ) ), array(‘post_tag’,’post_format’) );
$excluded_taxonomies = apply_filters( ‘avf_exclude_taxonomies’, $excluded_taxonomies, get_post_type( $the_id ), $the_id );if( ! empty( $taxonomies ) )
{
foreach( $taxonomies as $taxonomy )
{
if( ! in_array( $taxonomy, $excluded_taxonomies ) )
{
$terms .= get_the_term_list( $the_id, $taxonomy, ”, ‘, ‘, ” ) . ‘ ‘;
}
}$output .= $terms;
}June 21, 2021 at 3:30 am #1306634Also,
The code given to me is showing duplicates. For example the first post shows all the taxonomies once, the second post shows all the taxonomies of the first post AND second post, the third post shows the taxonomies of the first, second and third post etc.
June 22, 2021 at 4:33 am #1306842Hi,
Thank you for the inquiry.
Did you revert the postslider.php file back to default before adding the latest code? To exclude certain taxonomies, you have to include it in the array in this line.
$excluded_taxonomies = array_merge( get_taxonomies( array( ‘public’ => false ) ), array(‘post_tag’,’post_format’) );
Include the name of the taxonomy that you want to exclude in this array.
array(‘post_tag’,’post_format’)
Best regards,
IsmaelJune 23, 2021 at 7:26 am #1307081Thanks i was able to edit the array and remove unwanted taxonomies, however the duplicates are still there.
Yes i reverted the to the original postslider.php before updating the new one in my child theme. I even tried downloading the theme again and copied the fresh file to my theme to make sure its the same as the original. I used an online diffchecker to make sure that the two files are exactly the same except for the code to show the taxonomies.
June 25, 2021 at 7:23 am #1307406Hi,
Thank you for the update.
The login details from the previous thread is no longer working. Please post another login account so that we could check this properly again. Make sure that the Appearance > Editor panel is accessible.
Best regards,
IsmaelJune 25, 2021 at 7:42 am #1307408I have reset the password below. It shouldn’t expire, its not a temporary account.
June 28, 2021 at 7:24 am #1307665Hi,
Thank you for the update.
We just realized that the same code already exist in the file, so we removed the modification and edited the existing one. You can find it around line 817. The categories are now displaying above the post title.
Best regards,
IsmaelJune 28, 2021 at 7:43 am #1307669Perfect!
Thanks Ismael everything is working great
June 29, 2021 at 4:54 am #1307841Hi,
Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJune 29, 2021 at 6:43 am #1307864all good you can close this
June 29, 2021 at 7:47 am #1307873actually one more thing,
is there a way to tell which template i need to edit for specific archives? the archive pages for my custom posts are not displaying the ‘read more’ link. For example, compare the home page which uses postslider.php, to the page linked below
July 2, 2021 at 4:01 am #1308436Hi,
Glad to know that it is working correctly.
If you have any additional questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.
Thanks!
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.