• Resolved Sinkadus

    (@niwin)


    Hi yet again ??

    Is it somehow possible to activate/display current category class(es) in the body section of a single event post?

    Reason for asking: I would like to target a specific menu item and tie this (with CSS design) to the main category of an event post.

    Thanks, as always, for listening.

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Guido

    (@guido07111975)

    Hi,

    You would like to highlight the current menu item, am I right?

    I already use a function to add event cat(s) to the individual event container class.
    So for now you can use this snippet to add cat(s) to the single event body class:

    // add extra body class to single event
    function vsel_single_body_class($classes) {
    	if ( is_singular('event') ) {
    		$classes[] = vsel_event_cats();
    	}
    	return $classes;
    }
    add_filter('body_class', 'vsel_single_body_class', 11);

    I may add this to VSEL as well.

    Note: because the event cat(s) is(are) also being added to the individual event container (when using shortcode or widget), please check your styling afterwards. You may have to use a prefix to only target the menu-item on the single event page.

    Guido

    Thread Starter Sinkadus

    (@niwin)

    Yes – my aim is to keep the current parent menu item (category name) highlighted for single events, the same way as it already is on the landing page for that category. This works perfectly! Thanks! And thanks for the heads up regarding previous styling targeting the category class – its doesn’t seem to have affected my styling, so thats good.

    Seems like a good addition to the plugin. Question, when/if you do update the plugin with this, do I need to remove the function?

    Plugin Author Guido

    (@guido07111975)

    Hi,

    Because there’s no “current-menu-item” class (or something similar) being addded to the menu-item on the single event page, you should use the class of this menu-item with a prefix (use my fix for adding event category to body) to target that menu-item.

    .your-event-cat-slug .menu-item-51 a {background: #FFFF00; color: #000; padding: 2px 5px 5px 5px;}

    Guido

    Thread Starter Sinkadus

    (@niwin)

    Yes, thats how I’m planning to do it. Thanks for the code!

    Similar question: I added tags to events with this function:

    function reg_tag() {
         register_taxonomy_for_object_type('event', 'CUSTOM_POST_TYPE');
    }
    add_action('init', 'reg_tag');

    The tag(s) then gets inserted in the article section of the single event posts. But when I use the shortcode [vsel], the tag-class is not included as a class in the event id section:

    vsel-content folkets-bio video vsel-upcoming vsel-future (“video” there is a category, my tag “video” is “tag-video”, as shown here in the article section of a single event post:

    post-134 event type-event status-publish has-post-thumbnail hentry tag-video event_cat-folkets-bio event_cat-video grve-entry-item

    So, is it possible to have similar function that adds tag classes to event ID section of the shortcode output?

    Plugin Author Guido

    (@guido07111975)

    Hi,

    Because VSEL doesn’t normally use tags, this requires more custom code. And it cannot be done without changing plugin template file “vsel-page-template”, because you must hook into the individual event container (you described it as “event id section”). And I’m certain you know it’s not recommended to change plugin files.

    Guido

    Thread Starter Sinkadus

    (@niwin)

    Absolutely, just wanted to check if it an easy thing to add (like categories to body section).

    I can use a category for this instead, it just demands a few extra lines of custom css to hide this category etc.

    Thanks for the explanation ??

    Thread Starter Sinkadus

    (@niwin)

    Is it the same problem, if I wanted to display the tags on single pages? That you would need to edit plugin files?

    Plugin Author Guido

    (@guido07111975)

    Yes, if you want them inside the events details section you must make changes to template file as well. There are themes that let you hook into the content section of a post/page, so you can add your custom code. Maybe your theme has this feature as well?

    Guido

    Thread Starter Sinkadus

    (@niwin)

    Maybe, I’ll look into that. Thanks for clarifying!

    Plugin Author Guido

    (@guido07111975)

    Hi @niwin

    I have just updated plugin and the event categories are now added to the body of a single event. Every category has a prefix called “single-” so it’s possible to target the single event page only.

    Guido

    Plugin Author Guido

    (@guido07111975)

    Hi again @niwin

    Besides supporting the single event page (for obvious reasons) my plugin also supports native pages such as the search results page and event categories page. But there’s no reason to use these native pages because events are not listed on event date. My question for you, are you using native pages for listing events, besides the single event page?

    Guido

    Thread Starter Sinkadus

    (@niwin)

    Hi!

    No, I always use shortcode to display my events, because I always want to keep them in date order.

    Also: forgot to answer your other last answer here, so thanks for the update! works good ??

    Plugin Author Guido

    (@guido07111975)

    Thanks.
    I’m working on the settingspage, making it more easy to understand. Especially the settings regarding supporting these native pages.

    Guido

    Thread Starter Sinkadus

    (@niwin)

    Cool – sounds good!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Display category class in body section on single event’ is closed to new replies.