- This topic has 13 replies, 3 voices, and was last updated 5 years, 6 months ago by Tom.
-
AuthorPosts
-
October 4, 2018 at 1:03 pm #693655David
I am trying to get my custom taxonomy pages to reflect the same settings I am applying to my standard archive page (https://learn04.digitaldiplomats.com/category/news-and-info/). But it does not.
Is this achievable without coding? If coding is need, what files will need to be created to get the loop integrated in the custom taxonomy/post type pages?
Thanks
October 4, 2018 at 5:36 pm #693781TomLead DeveloperLead DeveloperHi David,
We’ll need to add a couple filters to achieve this.
Just to confirm, which settings should we be targeting? I’m seeing masonry, but is there anything else?
October 4, 2018 at 6:03 pm #693787DavidHi Tom,
For some reason, your reply wasn’t appearing on my mobile.
I’m using an Excerpt with a Word Count of 20. Displaying Read More as a Button. All so Displaying Tags.
For Featured Images, I have those set to Display, with padding. Title is below the image and centered.
Columns set to Display with 3 Columns. And Masonry.
Thanks.
October 4, 2018 at 6:10 pm #693789TomLead DeveloperLead DeveloperWord count and read more button should happen by default. Doesn’t look like any of those posts are long enough for them to apply.
The featured image settings should apply as well.
Columns and masonry:
add_filter( 'generate_blog_columns', 'tu_tax_columns' ); function tu_tax_columns( $columns ) { if ( is_tax( 'sait_division' ) ) { return true; } return $columns; } add_filter( 'generate_blog_masonry', 'tu_tax_masonry' ); function tu_tax_masonry( $masonry ) { if ( is_tax( 'sait_division' ) ) { return 'true'; } return $masonry; }
Tags and categories:
add_action( 'generate_after_entry_title', 'tu_tax_meta' ); function tu_tax_meta() { if ( is_tax( 'sait_division' ) ) : ?> <div class="entry-meta"> <?php generate_posted_on(); ?> </div><!-- .entry-meta --> <?php endif; }
Let me know if this gets us close ๐
October 4, 2018 at 6:23 pm #693791DavidHi Tom,
Quick reply, Thanks!
Now for the dumb question…where do I put the code? In the function.php or use elements-hook?
I’m a design/implementer…I’m been using and recommending GeneratePress for several years, but I never had to add code to it until now.
October 4, 2018 at 6:24 pm #693794LeoStaffCustomer SupportOne of these methods here:
Adding PHP: https://docs.generatepress.com/article/adding-php/October 4, 2018 at 6:27 pm #693799DavidThanks, Leo.
Perfect. I’ll try one of those tool in the morning. I actually read that page weeks ago, added the plugins in. Now I can actually use them.
Again, many thanks to you and Tom.
October 4, 2018 at 6:40 pm #693809LeoStaffCustomer SupportNo problem!
Let us know ๐
October 5, 2018 at 7:30 am #694162DavidGood morning,
I was able to use the code for columns and masonry. It worked for a single taxonomy, but code snippet came back with the following error code when I tried to add another version with a different taxonomy…
The code snippet you are trying to save produced a fatal error on line 8:
Cannot redeclare tu_tax_columns() (previously declared in /homepages/14/d119673623/htdocs/learn/learn04/wp-content/plugins/code-snippets/php/snippet-ops.php(353) : eval()’d code:2)
The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.I have a total of four taxonomies and two post types: Course Topic, Resource Topic, Resource Type, SAIT-Divison, Course Type and Knowledge Resource Type.
As for the tags and categories, the code did not work.
Thanks
October 5, 2018 at 1:12 pm #694487TomLead DeveloperLead DeveloperAh, you can add multiple taxonomies like this:
add_filter( 'generate_blog_columns', 'tu_tax_columns' ); function tu_tax_columns( $columns ) { if ( is_tax( array( 'sait_division', 'another_one', 'one_more' ) ) ) { return true; } return $columns; } add_filter( 'generate_blog_masonry', 'tu_tax_masonry' ); function tu_tax_masonry( $masonry ) { if ( is_tax( array( 'sait_division', 'another_one', 'one_more' ) ) ) { return 'true'; } return $masonry; }
So just the two functions with the multiple taxonomies on the same line.
As for the tags and categories – do your posts within these taxonomies have the core tags and categories enabled? Or are you using different taxonomies within them?
October 5, 2018 at 1:17 pm #694496DavidThe tags are core. I donโt need to display categories.
October 5, 2018 at 1:41 pm #694507TomLead DeveloperLead DeveloperSo instead of that tags/category function, try this:
add_action( 'generate_after_entry_title', 'tu_tax_meta' ); function tu_tax_meta() { if ( is_tax( array( 'sait_division', 'another_one', 'one_more' ) ) ) : ?> <div class="entry-meta"> <?php $tags_list = get_the_tag_list( '', ', ' ); if ( $tags_list ) { echo $tags_list; } ?> </div><!-- .entry-meta --> <?php endif; }
get_the_tag_list()
is a core WP functions, so it should work.October 5, 2018 at 2:47 pm #694525DavidHi Tom,
The first code work again. Thank you so very much.
The tags code didn’t, so I decided to make a new taxonomy for subject tags. You’ve helped me to get where I needed to go.
I can’t thank you guys enough.
David
October 5, 2018 at 7:06 pm #694616TomLead DeveloperLead DeveloperGlad I could help! ๐
-
AuthorPosts
- You must be logged in to reply to this topic.