- This topic has 19 replies, 3 voices, and was last updated 5 years, 1 month ago by Tom.
-
AuthorPosts
-
February 18, 2019 at 8:47 am #813684epickenyan
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?
February 18, 2019 at 5:17 pm #814072TomLead DeveloperLead DeveloperHi there,
Not super easily, but it should be do-able. Any chance you can link me to your site?
February 18, 2019 at 10:55 pm #814205epickenyanHi.
February 19, 2019 at 8:34 am #814736TomLead 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; }
February 19, 2019 at 9:15 am #814762epickenyanThis is the result. http://prntscr.com/mnaa5d
February 19, 2019 at 3:09 pm #814964TomLead DeveloperLead DeveloperHmm, that looks like the PHP isn’t working. How did you add it?
Any chance I can see the site?
February 19, 2019 at 9:23 pm #815112epickenyanI 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 #815370DavidStaffCustomer SupportHi there,
just to test, can you try adding the code using the Code Snippets plugin, a link is contained within this article:
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 #815451DavidStaffCustomer 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
February 20, 2019 at 8:33 am #815712epickenyanJust did. Result still as screenshot.
February 20, 2019 at 10:03 am #815801TomLead 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 ); } } } );
February 20, 2019 at 11:35 am #815894epickenyanAre 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 #816072TomLead 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 ); } } } );
February 21, 2019 at 2:32 am #816312epickenyanThat 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.