add html above calendar for a specific a category.Continued

Home Forums Calendar Products Events Calendar PRO add html above calendar for a specific a category.Continued

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #116366
    Sean
    Participant

    Barry didn’t really address my question and closed the ticket so to continue…

    this function adds html above a calendar for a specific category, it adds the html fine above anything entered in event settings >> display tab >> Advanced Template Settings >> Add HTML before event content.

    add_filter( 'tribe_events_before_html', 'add_text_before_events' );
    function add_text_before_events( $html ) {
    if ( tribe_meta_event_category_name() == "CATEGORY NAME" ) $html = '<p> HTML </p>' . $html;
    return $html;
    }

    the desired result is to have it overwrite anything that is in event settings >> display tab >> Advanced Template Settings >> Add HTML before event content for the specified category.

    i assumed if i removed “. $html” from the condition it would not include the html contained in event settings >> display tab >> Advanced Template Settings >> Add HTML before event content.
    add_filter( 'tribe_events_before_html', 'add_text_before_events' );
    function add_text_before_events( $html ) {
    if ( tribe_meta_event_category_name() == "CATEGORY NAME" ) $html = '<p> HTML </p>';
    return $html;
    }

    this works BUT breaks the page as if there is closing div missing.

    is this the correct way to overwrite what is contained in event settings >> display tab >> Advanced Template Settings >> Add HTML before event content for a specific category?

    Thank You

    Sean

    #116371
    Barry
    Member

    Hi Sean:

    Sorry if you feel I closed that prematurely – but if you want to wipe any custom before-HTML text as specified in the Events > Display admin screen the basic strategy would be:

    add_filter( 'tribe_get_option', 'wipe_before_html_content', 10, 2 );
    
    function wipe_before_html_content( $option_val, $option_name ) {
    	if ( 'tribeEventsBeforeHTML' === $option_name ) return '';
    	return $option_val;
    }

    Does that help?

    #116395
    Sean
    Participant

    its ok, that happens to all guys at some point…

    this should help, looks like i need 2 functions. so where specifically in the new documentation would i find this information? i am all about self help… when i can find it 🙂

    #116778
    Barry
    Member

    Hi!

    this should help, looks like i need 2 functions

    Or indeed you could use a single filter function like in my above example (instead of returning an empty string, you could return whatever you want if your specific conditions are met).

    so where specifically in the new documentation would i find this information? i am all about self help… when i can find it

    Our current stack of learning resources is basically as follows:

    And of course past answers on the forum augment this. We do realize there are some gaps and hope to continue building on and improving these resources.

    I hope that helps!

    #122548
    Barry
    Member

    <p>This thread’s not seen much activity for the last couple of weeks – and there’s not too much more we can offer here given its a customization – so I’ll go ahead and close it. Of course if you still need help with this or any other issue please don’t hesitate to create a new thread (or threads) and one of the team will be only too happy to help. Thanks!</p>

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘add html above calendar for a specific a category.Continued’ is closed to new replies.