- This topic has 19 replies, 3 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
February 18, 2019 at 8:47 am #813684
epickenyan
Hi. Is there a way to move the category meta on blog layout to the inside of image like shown here http://prntscr.com/mms0nx?
GeneratePress 2.2.2GP Premium 1.7.7February 18, 2019 at 5:17 pm #814072Tom
Lead DeveloperLead DeveloperHi there,
Not super easily, but it should be do-able. Any chance you can link me to your site?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 18, 2019 at 10:55 pm #814205epickenyan
Hi.
February 19, 2019 at 8:34 am #814736Tom
Lead DeveloperLead DeveloperFirst, add this PHP:
add_filter( 'generate_category_list_output', '__return_false' ); add_action( 'generate_before_content', function() { if ( is_archive() ) { $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) ); if ( $categories_list ) { printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', _x( 'Categories', 'Used before category names.', 'generatepress' ), $categories_list ); } } } );
Then, add this CSS:
span.cat-links { margin-bottom: 30px; display: block; margin-top: -70px; } span.cat-links a { color: #fff; display: inline-block; background: #000; padding: 2px 5px; } .cat-links:before { display: none; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 19, 2019 at 9:15 am #814762epickenyan
This is the result. http://prntscr.com/mnaa5d
February 19, 2019 at 3:09 pm #814964Tom
Lead DeveloperLead DeveloperHmm, that looks like the PHP isn’t working. How did you add it?
Any chance I can see the site?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 19, 2019 at 9:23 pm #815112epickenyan
I added to functions.php. Or should I have added it anywhere else? I didn’t know which hook to target specifically. The site link I did share up there.
February 20, 2019 at 4:38 am #815370David
StaffCustomer SupportHi there,
just to test, can you try adding the code using the Code Snippets plugin, a link is contained within this article:
https://docs.generatepress.com/article/adding-php/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 20, 2019 at 6:17 am #815445epickenyan
@david. The problem is not adding the code per se, but the output.
February 20, 2019 at 6:32 am #815451David
StaffCustomer SupportThe suggestion to try the Code Snippets plugin was to see if it the code worked and then we can look at why its not working within the Functions.php
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 20, 2019 at 8:33 am #815712epickenyan
Just did. Result still as screenshot.
February 20, 2019 at 10:03 am #815801Tom
Lead DeveloperLead DeveloperIs it not possible to see the site itself to debug?
This function specifically should be outputting something on the archives:
add_action( 'generate_before_content', function() { if ( is_archive() ) { $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) ); if ( $categories_list ) { printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', _x( 'Categories', 'Used before category names.', 'generatepress' ), $categories_list ); } } } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 20, 2019 at 11:35 am #815894epickenyan
Are you not able to see this comment? I forgot to include a link in original post https://generatepress.com/forums/topic/move-category-meta/#post-814205. And just to be clear, are we still speaking about moving category to inside image as shared in the screenshot above?
February 20, 2019 at 5:01 pm #816072Tom
Lead DeveloperLead DeveloperUgh, sorry – totally missed that.
Try this:
add_action( 'generate_before_content', function() { if ( is_archive() || is_home() ) { $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) ); if ( $categories_list ) { printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', _x( 'Categories', 'Used before category names.', 'generatepress' ), $categories_list ); } } } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 21, 2019 at 2:32 am #816312epickenyan
That makes it appear twice on the homepage and archives. I will just mark this as resolved because I think it is not practical. Thanks for the help though. Appreciated.
-
AuthorPosts
- You must be logged in to reply to this topic.