Adding Content Above or Below Community Events Pages

You may want to include some instructions for your users at the top of the Community Events submission form, or add some notes or sponsor information at the bottom of the "My Events" page. But the Community Events submission form and "My Events" pages are not actual WordPress pages, so to add content above or below these pages, you'll need to use on of the following three methods.

The available methods are sorted in this guide in order of difficulty, with the easiest method first. The three methods are as follows:


Method One: Events Settings

The simplest and quickest way to add content above or below Community Events pages is to head to Events > Settings > Display in your site's wp-admin and then scroll down to the "Advanced Template Settings" section of this page. In this section, you'll see two options: Add HTML before event content and Add HTML after event content.

The names of these options are descriptive and reveal their functionality: Whatever content you add for the Add HTML before event content option, for example, gets displayed atop all event pages. Whatever content you add for the Add HTML after event content option, meanwhile, gets displayed below all event pages.

"All event pages" is highlighted above because, while this first method is simple, the content gets added to all main event pages: it'll be added above/below the Community Events submission and "My Events" pages, but will also be added above/below the main calendar page on your site.

This method is quick, very simply, and effective—but not specific to Community Events pages. To get more specific control over your custom content and limit it to only show above/below Community Events pages, read on.


Method Two: PHP Template Tags

The problem with Method One is that it applies the content to all main events pages. If you want to add content above or below Community Events pages—and only above these pages, not any other calendar pages—then using template tags may be a great solution.

There are four main template tags that would work well in this situation, which are as follows:

  • tribe_events_community_form_before_template
    • A template tag for adding content above the Community Events submission page.
  • tribe_events_community_form_after_template
    • A template tag for adding content below the Community Events submission page.
  • tribe_ce_before_event_list_top_buttons
    • A template tag for adding content above the "My Events" page.
  • tribe_ce_after_event_list_table
    • A template tag for adding content below the "My Events" page.

You can use the same callback function a number of times, which will be exemplified as follows: Let's say you wanted to add a simple bit of text, "Sponsored by Modern Tribe", atop the Community Events submission page only. You could write a code snippet like this to do just that:

function tribe_add_community_sponsor_message() {
    echo 'Sponsored by <a href="http://tri.be">Modern Tribe</a>';
}

add_action( 'tribe_events_community_form_before_template', 'tribe_add_community_sponsor_message' );

☝️ This would add the sponsor text above the submission page, but no place else.

If you wanted to add this bit of content to all four locations, then you would just tie the callback function (which is tribe_add_community_sponsor_message, in the case of this example) to all four template tags, like this:

function tribe_add_community_sponsor_message() {
    echo 'Sponsored by <a href="http://tri.be">Modern Tribe</a>';
}

// Above the submission page content.
add_action( 'tribe_events_community_form_before_template', 'tribe_add_community_sponsor_message' );

// Below the submission page content.
add_action( 'tribe_events_community_form_after_template', 'tribe_add_community_sponsor_message' );

// Above the "My Events" list page content.
add_action( 'tribe_ce_before_event_list_top_buttons', 'tribe_add_community_sponsor_message' );

// Below the "My Events" list page content.
add_action( 'tribe_ce_after_event_list_table', 'tribe_add_community_sponsor_message' );

Method Three: Custom Theme Templates

For a truly advanced level of control and customization ability, you may want to make custom theme templates for the Community Events templates outright. This would let you heavily customize the layout of these pages to suit your needs, and would allow for the easier addition of things like iFrames, video embeds, inline JavaScript, and complex HTML layouts of content.

To learn about making custom theme templates, check out our Themer's Guide here.