Display categories (or taxonomies) in homepage grid

Home Forums Receptar Display categories (or taxonomies) in homepage grid

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #21794
    ferranroigtio
    Participant

    Display categories (or taxonomies) in homepage grid

    Resolved

    Hey there! Have you noticed this support service is provided FREE of charge?
    If you like the speed and accuracy of resolutions, please consider supporting me with a small donation. Thank you

    Consider a donation →

    Hi there,

    I’d like to show the taxonomies of every post together with their title and excerpt in the homepage, where posts are listed in a beautiful grid.

    Is there an easy way to achieve this?

    Regards,

    #21797
    Oliver Juhas
    Keymaster

    Hi ferranroigtio,

    I’m sorry, but I’m not quite sure what you aim for.

    There already are posts displayed in the grid and they display post excerpt and title.

    Do you need to display post category in each post too? Or could you please describe the issue in more details? What taxonomy would you like to display and where exactly?

    Best regards,

    Oliver Juhas
    WebMan Design

    #21798
    ferranroigtio
    Participant

    Yes, sorry, I wasn’t very accurate in my previous description.

    All my posts are possible weekend plans. I work with three taxonomies to help users find their desired plan. These taxonomies are: distance, cost and modality. Possible values for these taxonomies are shown below:
    – Distance: Walking, Bus, Farther
    – Cost: Free, Cheap, Expensive
    – Modality: Adventure, Culture, Social

    I would like these values for each post to be displayed over the title or nearby, so that the user would get this information at once.

    Let me know if it’s still not quite clear.

    Thank you for your support.

    #21799
    Oliver Juhas
    Keymaster

    Hi ferranroigtio,

    The theme is full of useful hooks, so you could do something like this in your child theme‘s functions.php file:

    function child_theme_post_taxonomy() {
    	if ( is_single() ) {
    		return;
    	}
    
    	the_terms( get_the_ID(), 'my_taxonomy_key', 'My taxonomy: ', $sep = ', ' );
    }
    add_action( 'wmhook_entry_top', 'child_theme_post_taxonomy', 30 );

    Surely, adapt the code to your needs. You can additionally wrap the the_terms() WordPress function in some HTML and repeat it how many times you need (for each taxonomy). Also, you will need to apply some custom CSS to style the result. I also can not guarantee any good result as the theme was never designed for this type of display, so you’ll need to test on different screens sizes too.

    Best regards,

    Oliver Juhas
    WebMan Design

    #21850
    ferranroigtio
    Participant

    Hi, Oliver.

    Thank you for your quick reply.

    I have two questions regarding your insight at this moment:
    1) Should I download a sample child theme? The “Create and activate now” link doesn’t seem to be available for Receptar, is it?
    2) I copy-pasted your function at the end of functions.php, just to try it. I changed ‘my_taxonomy_key’ to fit my requirements. As a result, nothing changed. I wonder whether I have to use the tag ‘wmhook_entry_top’ somewhere else for everything to work…

    Regards,

    #21851
    Oliver Juhas
    Keymaster

    Hi ferranroigtio,

    1. Sure, you can. I’m not sure what you mean by “Create and activate now” but there is no child theme generator in the theme if you mean that. Such functionality is actually not allowed in free WordPress repository themes. Go ahead, download and modify my sample child theme.
    2. The code works perfectly fine for me. Please make sure you are using correct my_taxonomy_key. You can get the taxonomy key from the taxonomy admin page:

    Best regards,

    Oliver Juhas
    WebMan Design

    #21872
    ferranroigtio
    Participant

    Thank you Oliver Juhas,

    That was very helpful!

    Take care,

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.