{"id":1896551,"date":"2019-10-18T13:19:26","date_gmt":"2019-10-18T17:19:26","guid":{"rendered":"https:\/\/theeventscalendar.com\/knowledgebase\/configuring-the-event-list-widget\/"},"modified":"2026-04-14T12:02:50","modified_gmt":"2026-04-14T16:02:50","slug":"event-list-widget","status":"publish","type":"post","link":"https:\/\/theeventscalendar.com\/knowledgebase\/event-list-widget\/","title":{"rendered":"Events List Widget"},"content":{"rendered":"\n<p>We&#8217;re going to go over the Events List Widget in this tutorial, including how to configure it, things to expect from it, and perhaps some tips and tricks you can use at your next cocktail party. You&#8217;ll be the star of the show, for sure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding\">Adding the Widget to a Sidebar<\/h2>\n\n\n\n<p>The first thing to note about the Events List widget is where to find it. The widget&nbsp;comes packaged with the core version of <a href=\"https:\/\/theeventscalendar.com\/product\/wordpress-events-calendar\/\" target=\"_blank\" rel=\"noreferrer noopener\">The Events Calendar<\/a> (free). You&#8217;ll find it in <strong>Appearance &gt; Widgets<\/strong> from the WordPress dashboard.&nbsp;<\/p>\n\n\n\n<p>You can use this widget to display your calendar on pages other than your default events page. Drag that little guy into the sidebar area of your choice, and you&#8217;re off to the races!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"488\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/events-list-free-1024x488.png\" alt=\"\" class=\"wp-image-1964774\" style=\"aspect-ratio:1.6797385620915033;width:1004px;height:auto\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/events-list-free-1024x488.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/events-list-free-300x143.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/events-list-free-768x366.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/events-list-free.png 1098w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"settings\">Events Widget Settings<\/h2>\n\n\n\n<p>There are three settings that help customize the Events List widget experience. Let&#8217;s take a look at them:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Title:<\/strong> This is the heading that sits above the widget. By default, this is &#8220;Upcoming Events,&#8221; but it can be changed to anything you&#8217;d like.<\/li>\n\n\n\n<li>Show: This is the maximum number of events you want to display at any given time. Five is the default, but this can be any number between one and ten.<\/li>\n\n\n\n<li>Hide this widget if there are no upcoming events:&nbsp;Check the box for this option and the widget will automatically hide itself if there are no relevant events to list. Otherwise, it will display a handy notice saying there are no upcoming events at this time.<\/li>\n\n\n\n<li>Limit to featured events only:&nbsp;Check the box for this option, and the widget will display <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/featured-events\/\" target=\"_blank\" rel=\"noreferrer noopener\">featured events<\/a>.<\/li>\n\n\n\n<li><strong>Generate JSON-LD data:<\/strong> Enable this setting if you would like to enable <a href=\"https:\/\/developers.google.com\/search\/docs\/data-types\/events\" target=\"_blank\" rel=\"noreferrer noopener\">structured data<\/a> in the widget. Structured data is what search engines use to recognize calendar content on and display events in the search results if the data is there and processed by the search engine.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuring\">Premium Widget Options<\/h2>\n\n\n\n<p>It&#8217;s important to bear&nbsp;in mind that the Events List widget in <a href=\"https:\/\/theeventscalendar.com\/product\/wordpress-events-calendar-pro\/\" target=\"_blank\" rel=\"noreferrer noopener\">The Events Calendar Pro<\/a> is the same widget that comes with the core version of The Events Calendar. If you have Pro, you&#8217;ll see the same Events List widget under <strong>Appearance &gt; Widgets<\/strong>. In your frontend the Widget will have the same appearance; the only difference is that you have some more filtering options available to set up this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"\/knowledgebase\/wp-content\/uploads\/2020\/12\/the-events-calendar-event-list-widget.png\" alt=\"Event List Widget in The Events Calendar vs Events Calendar Pro\" class=\"wp-image-1948528\" style=\"width:677px;height:678px\"\/><\/figure>\n\n\n\n<p>As you can see, there are more&nbsp;configurable options when setting up the Pro widget. Add the widget to the sidebar the same way as described above, and now you&#8217;ll see more options. In addition to the same three options in the basic widget, Pro introduces these settings:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"624\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/sidebar-events-list-1024x624.png\" alt=\"\" class=\"wp-image-1964772\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/sidebar-events-list-1024x624.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/sidebar-events-list-300x183.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/sidebar-events-list-768x468.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/sidebar-events-list.png 1149w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Display:<\/strong>&nbsp;This is a set of checkboxes that allow you to toggle the display of different bits of information, including:\n<ul class=\"wp-block-list\">\n<li>Venue<\/li>\n\n\n\n<li>Organizer<\/li>\n\n\n\n<li>Street<\/li>\n\n\n\n<li>City <\/li>\n\n\n\n<li>State (US) or Province (Int)<\/li>\n\n\n\n<li>Postal Code<\/li>\n\n\n\n<li>Country<\/li>\n\n\n\n<li>Venue Phone<\/li>\n\n\n\n<li>Price <\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Filter:<\/strong> This is an advanced setting that allows you to filter the events that display in the widget by a number of variables, including Categories and Tags. You can add multiple filters and also multiples instances of the widget- so if you wanted, you could have different widgets for different Event categories<\/li>\n<\/ul>\n\n\n\n<p>Please note that all that settings are responsible only for properly loading events from your database. They don&#8217;t add or remove any visual information in the Widget!<\/p>\n\n\n\n<p>Phew, that&#8217;s a lot of stuff! You really have a lot of options here to customize the widget&#8217;s content without touching a line of code, and that&#8217;s awesome.<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id=\"h-widget-block\">Widget Block<\/h2>\n\n\n\n<p>When using the Block Editor, you can add the Events List as a block instead. Simply search for Events List under blocks, and you&#8217;ll find all of the same available options.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2021\/11\/Screen-Shot-2021-11-15-at-2.22.23-PM.png\" alt=\"Events List block\" class=\"wp-image-1951274\"\/><\/figure>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-embedding-the-widget-with-a-shortcode\">Embedding the Widget with a Shortcode<\/h2>\n\n\n\n<p>To embed the advanced list widget, simply use the following shortcode:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;tribe_events_list]\n<\/pre><\/div>\n\n\n<p>The widget also comes complete with an advanced set of filtering options, and these can also be used with the shortcode. Here&#8217;s an example that looks for events in the <em>party<\/em> category:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;tribe_events_list category=&quot;party&quot;]\n<\/pre><\/div>\n\n\n<p>We can supply a list of several categories or tag slugs (we just need to separate them with commas), and we can also use IDs by prefixing them with the <strong>#<\/strong> symbol:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;tribe_events_list categories=&quot;party, black-tie&quot; tag=&quot;#512&quot;]\n<\/pre><\/div>\n\n\n<p>You can also add a tax-operand attribute to the calendar so that multiple categories or tags can display at once:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;tribe_events_list tags=&quot;cabbage, broccoli&quot; tax-operand=&quot;AND&quot;]\n<\/pre><\/div>\n\n\n<p>Also, just like the advanced list widget itself, it is possible to specify extra information which should be displayed, such as the phone number and address of each venue:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;tribe_events_list phone=&quot;yes&quot; address=&quot;yes&quot;]\n<\/pre><\/div>\n\n\n<p>Here&#8217;s a complete list of those optional details:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>venue (supports multiple venues)<\/li>\n\n\n\n<li>country<\/li>\n\n\n\n<li>street<\/li>\n\n\n\n<li>city<\/li>\n\n\n\n<li>region<\/li>\n\n\n\n<li>zip<\/li>\n\n\n\n<li>phone<\/li>\n\n\n\n<li>cost<\/li>\n\n\n\n<li>organizer<\/li>\n<\/ul>\n\n\n\n<p>Finally, you can specify the maximum number of events that should be listed:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;tribe_events_list limit=&quot;10&quot;]\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-customizing-the-widget-0\">Customizing the Widget<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-styling-with-css\"><strong>Styling with CSS<\/strong><\/h3>\n\n\n\n<p>You can apply custom CSS to the Events List widget to change its appearance. The widget&#8217;s styles are loaded from <code>widget-events-list-full.css<\/code>. To target the widget with your own CSS rules, use the base class:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.tribe-events-widget-events-list {\n    \/* your styles here *\/\n}\n<\/pre><\/div>\n\n\n<p>For guidance on where to add custom CSS and how widget stylesheets work, see our <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/customizing-css\/\">Customizing CSS<\/a> guide.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"V2\">Using Calendar Views<\/h3>\n\n\n\n<p>The template for the core Events List widget can be found at: <code>\/plugins\/the-events-calendar\/src\/views\/v2\/widgets\/widget-events-list.php<\/code>. This single file contains all the content and functionality for the widget. To override it, make a copy of it, then:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Make a new folder in the theme directory called&nbsp;<em>tribe<\/em><\/li>\n\n\n\n<li>Inside the new <em>tribe<\/em> folder make a new folder called <em>events<\/em><\/li>\n\n\n\n<li>Inside events folder, make a folder called <em>v2<\/em><\/li>\n\n\n\n<li>Make a folder in that one called&nbsp;<em>widgets<\/em><\/li>\n\n\n\n<li>Drop the&nbsp;widget-events-list.php copied file in that last folder<\/li>\n<\/ul>\n\n\n\n<p>Now that the template is in the theme, you can modify it to your liking. For example, you can customize&nbsp;the notice for when there are no upcoming events by changing this line:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\n&lt;?php $this-&gt;template( &#039;components\/messages&#039; ); ?&gt;\n<\/pre><\/div>\n\n\n<p>&#8230;to something like:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\n &lt;p&gt; No events here. Holla! &lt;\/p&gt;\n<\/pre><\/div>\n\n\n<p>The process for customizing the widget in Events Calendar Pro is very similar. Actually both Free and Pro version of The Events Calendar uses the same file to displays the widget. The main difference here is that Pro version gives you more filtering options in WordPress dashboard.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-remove-the-end-date-time\">Remove the End Date\/Time<\/h3>\n\n\n\n<p>As you may have noticed, there isn&#8217;t an option to hide the end date\/time. If you need to do so, the following code snippet will help you achieve that. Be sure to check out our <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/best-practices-for-implementing-custom-code-snippets\/\">snippet guide<\/a> for information on how to apply the code snippet to your site.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\nadd_filter ( &#039;tribe_events_event_short_schedule_details&#039;, function ( $schedule ) {\n\t$dash_position = strpos( $schedule, &#039;&gt; - &#039; );\n\t$schedule = substr( $schedule, 0, $dash_position );\n\treturn $schedule;\n} );\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-change-the-view-calendar-link\">Change the &#8216;View Calendar&#8217; Link<\/h3>\n\n\n\n<p>The &#8216;View All Events&#8217; link in the Events List widget defaults to the main events archive page set under Events &gt; Settings &gt; General &gt; Viewing. By default, this is the <code>\/events\/<\/code> slug.<\/p>\n\n\n\n<p>If you have created a custom page to display your calendar using a shortcode, or if you&#8217;ve simply changed the main calendar slug, you&#8217;ll need to update this link to point to your new URL.<\/p>\n\n\n\n<p>This guide provides a simple code snippet to update the destination URL for the &#8216;View All Events&#8217; link in the Events List widget.<\/p>\n\n\n\n<p>This snippet uses jQuery to select the &#8216;View More&#8217; link in the Events List widget (<code>.tribe-events-widget-events-list__view-more<\/code>) and updates its <code>href<\/code> attribute to a custom URL.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nadd_action( &#039;wp_footer&#039;, function() {\n?&gt;\n&amp;lt;script&gt;\njQuery(document).ready(function($) {\n  \/\/ Replace &#039;https:\/\/example.com\/new-page\/&#039; with your desired custom URL\n  var customCalendarUrl = &#039;https:\/\/example.com\/new-page\/&#039;;\n\n  \/\/ Target the &#039;View All Events&#039; link in the Events List widget\n  $(&#039;.tribe-events-widget-events-list__view-more a&#039;)\n    .attr(&#039;href&#039;, customCalendarUrl);\n});\n&amp;lt;\/script&gt;\n&amp;lt;?php\n} );\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">How to Use the Code<\/h4>\n\n\n\n<p><strong>Replace the URL:<\/strong> Change the dummy URL <code>'https:\/\/example.com\/new-page\/'<\/code> to the exact URL of your custom calendar page.<\/p>\n\n\n\n<p><strong>Add the snippet:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add the code to your child theme&#8217;s <strong><code>functions.php<\/code><\/strong> file.<\/li>\n\n\n\n<li><strong>Or<\/strong>, preferably, use a dedicated <strong>Code Snippet plugin<\/strong> for easier management.<\/li>\n<\/ul>\n\n\n\n<p>Clear any site cache (plugin, server, or CDN) to ensure the new code is loaded on the front end.<\/p>\n\n\n\n<p>For more information, please see our guide on the <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/best-practices-for-implementing-custom-code-snippets\/\">best practices for implementing custom code snippets<\/a>.<\/p>\n\n\n\n<p>This approach is simpler than <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/customizing-template-files-2\/\">overriding the widget&#8217;s template file<\/a>, and ensures the &#8216;View All Events&#8217; link points to your custom URL.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hide-the-view-calendar-link\">Hide the \u201cView Calendar\u201d Link<\/h3>\n\n\n\n<p>You can completely disable the link using a PHP snippet. Add the following code to your theme&#8217;s <code>functions.php<\/code> file or through a plugin like <strong><a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\">Code Snippets<\/a><\/strong>. Using this method if you want to remove the link from the DOM entirely (cleaner code output).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter( 'tribe_template_pre_html:events\/v2\/widgets\/widget-events-list\/view-more', '__return_false' );<\/code><\/pre>\n\n\n\n<p>This method removes the link from the HTML entirely, so it won\u2019t be rendered on the frontend. <\/p>\n\n\n\n<p>If you&#8217;d rather keep the markup and just visually hide the link, you can use this CSS snippet instead. Use this method if you prefer a non-invasive method that only affects the visual display.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.tribe-events-widget-events-list__view-more {display: none !important;}<\/code><\/pre>\n\n\n\n<p>You can add the CSS code in one of the following ways:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Via <strong>Customizer<\/strong>: Appearance \u2192 Customize \u2192 Additional CSS<\/li>\n\n\n\n<li>In your theme or child theme\u2019s <code>style.css<\/code> file<\/li>\n\n\n\n<li>Through a custom CSS plugin<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-show-newest-published-events\">Show Newest Published Events<\/h3>\n\n\n\n<p class=\"p1\">By default, the <span style=\"text-decoration: underline;\"><a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/configuring-the-event-list-widget\/\">Events List Widget<\/a><\/span> in <span style=\"text-decoration: underline;\"><a href=\"https:\/\/theeventscalendar.com\/\">The Events Calendar<\/a><\/span> displays upcoming events in order of their event start date.<\/p>\n\n\n\n<p>But what if you want to sort events by <strong>when they were published<\/strong> instead of when they take place? This would allow you to showcase the most recently added events, regardless of their start date.<\/p>\n\n\n\n<p>Fortunately, with a simple code snippet, you can modify the Events List Widget to display events by <strong>publication date (newest first)<\/strong> instead.<\/p>\n\n\n\n<p>The snippet below customizes the widget\u2019s behavior. You can add it as a standalone plugin or insert it into your theme\u2019s <code>functions.php<\/code> file. Once in place, list widgets will prioritize newly published events instead of upcoming ones.<\/p>\n\n\n\n<p>If you don\u2019t want this change to apply to <strong>all<\/strong> List Widgets, you can add constraints to target specific widgets or sidebars.<\/p>\n\n\n\n<p>For example, if you only want this behavior for a widget titled <strong>&#8220;Newly Added&#8221;<\/strong>, modify the following line at the bottom of the snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nnew EventsListWidget_NewlyAddedEvents();\n<\/pre><\/div>\n\n\n<p>&#8230;to this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nnew EventsListWidget_NewlyAddedEvents( array(\n  &#039;widget_title&#039; =&gt; &#039;Newly Added&#039;\n) );\n<\/pre><\/div>\n\n\n<p>This ensures that only the <strong>&#8220;Newly Added&#8221;<\/strong> widget adopts the new sorting behavior while others remain unchanged.<\/p>\n\n\n\n<p>Check out the snippet below to implement this feature!<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php \/\/Do not copy this line\n\nclass EventsListWidget_NewlyAddedEvents {\n\tprotected $constraints = array(\n\t\t&#039;sidebar_id&#039;   =&gt; null,\n\t\t&#039;widget_id&#039;    =&gt; null,\n\t\t&#039;widget_title&#039; =&gt; null\n\t);\n\n\tpublic function __construct( array $constraints = array() ) {\n\t\t$this-&gt;constraints = array_merge( $this-&gt;constraints, $constraints );\n\t\tadd_filter( &#039;widget_display_callback&#039;, array( $this, &#039;setup&#039; ), 10, 3 );\n\t}\n\n\tpublic function setup( $instance, $widget, $args ) {\n\t\t\/\/ We&#039;re interested only in the (advanced or regular) events list widgets\n\t\t$targets = array( &#039;tribe-events-adv-list-widget&#039;, &#039;tribe-widget-events-list&#039; );\n\t\tif ( ! in_array( $widget-&gt;id_base, $targets ) ) {\n\t\t\treturn $instance;\n\t\t}\n\n\t\t\/\/ Check for constraints\n\t\tif ( ! $this-&gt;constraints_met( $instance, $args ) ) {\n\t\t\treturn $instance;\n\t\t}\n\n\t\t\/\/ Modify behavior\n\t\tadd_filter( &#039;tribe_events_views_v2_widget_repository_args&#039;, array( $this, &#039;order_by_latest&#039; ) );\n\n\t\treturn $instance;\n\t}\n\n\tprotected function constraints_met( $instance, $args ) {\n\t\t$fail = false;\n\n\t\t\/\/ Should only run within a specific sidebar?\n\t\tif ( ! is_null( $this-&gt;constraints&#x5B;&#039;sidebar_id&#039;] ) &amp;&amp; $this-&gt;constraints&#x5B;&#039;sidebar_id&#039;] !== $args&#x5B;&#039;id&#039;] ) {\n\t\t\t$fail = true;\n\t\t}\n\n\t\t\/\/ Should only run in relation to a specific instance of the widget?\n\t\tif ( ! is_null( $this-&gt;constraints&#x5B;&#039;widget_id&#039;] ) &amp;&amp; $this-&gt;constraints&#x5B;&#039;widget_id&#039;] !== $args&#x5B;&#039;widget_id&#039;] ) {\n\t\t\t$fail = true;\n\t\t}\n\n\t\t\/\/ Should only run when the widget title is set to something specific?\n\t\tif ( ! is_null( $this-&gt;constraints&#x5B;&#039;widget_title&#039;] ) &amp;&amp; $this-&gt;constraints&#x5B;&#039;widget_title&#039;] !== $instance&#x5B;&#039;title&#039;] ) {\n\t\t\t$fail = true;\n\t\t}\n\n\t\treturn ! $fail;\n\t}\n\n\tpublic function order_by_latest( $args ) {\n\n\t\t\/\/ Don&#039;t interfere in other queries\n\t\tremove_filter( &#039;tribe_events_views_v2_widget_repository_args&#039;, array( $this, &#039;order_by_latest&#039; ) );\n\n\t\t\/\/ Tweak the actual orderby clause\n\t\tadd_filter( &#039;posts_orderby&#039;, array( $this, &#039;override_orderby&#039; ), 100 );\n\n\t\treturn $args;\n\t}\n\n\tpublic function override_orderby( $orderby_sql ) {\n\t\tglobal $wpdb;\n\n\t\t\/\/ Don&#039;t interfere in other queries\n\t\tremove_filter( &#039;posts_orderby&#039;, array( $this, &#039;override_orderby&#039; ) );\n\n\t\treturn &quot;$wpdb-&gt;posts.post_date DESC, $orderby_sql&quot;;\n\t}\n}\n\nnew EventsListWidget_NewlyAddedEvents();\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-adding-the-event-featured-image\">Adding the Event Featured Image<\/h3>\n\n\n\n<p>If you find yourself thinking, &#8220;The event list widget design is <em>great<\/em>, but I wish it showed the event&#8217;s featured image,&#8221; well, we&#8217;ve got something for you. In fact, we have three approaches to do just that.<\/p>\n\n\n\n<p>Let&#8217;s walk through those together!<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-what-we-re-making\">What We&#8217;re Making<\/h4>\n\n\n\n<p>In short, we&#8217;re adding a thumbnail of the featured image for each event that is displayed in the widget.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/knowledgebase\/wp-content\/uploads\/2020\/11\/List_Widget-1024x827.png\" alt=\"\" class=\"wp-image-1948491\"\/><figcaption class=\"wp-element-caption\">Before<\/figcaption><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/knowledgebase\/wp-content\/uploads\/2020\/11\/List_Widget_Filter_Images-1024x899.png\" alt=\"\" class=\"wp-image-1948492\"\/><figcaption class=\"wp-element-caption\">After<\/figcaption><\/figure>\n<\/div>\n<\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-the-nice-and-neat-way\">The Nice and Neat Way<\/h4>\n\n\n\n<p>We&#8217;ve got the nice-and-neat way (which we recommend because we like things neat, <em>and<\/em> you get to learn how the <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/calendar-template-files-v2\/#Widgets\" target=\"_blank\" rel=\"noreferrer noopener\">plugin templates<\/a> work).<\/p>\n\n\n\n<p>As we&#8217;ve discussed before in <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/template-hooks\/\" target=\"_blank\" rel=\"noreferrer noopener\">other<\/a> <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/using-template-filters-and-actions\/\" target=\"_blank\" rel=\"noreferrer noopener\">articles<\/a>, our new templating system is chock-full of actions and filters that allow for fine-tuned customization. If what we want is to simply jam an image in there, we can do that with a couple of hooks.<\/p>\n\n\n\n<p>Open up your <code>functions.php<\/code> file. It&#8217;s located at the top level of your theme folder. Then add this snippet at the bottom of the file:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n\/\/ Here we hook into our template action - just before the date tag, which is the first item in the container.\nadd_action(\n  &#039;tribe_template_after_include:events\/v2\/widgets\/widget-events-list\/event\/date-tag&#039;,\n  &#039;my_action_add_event_featured_image&#039;,\n  15,\n  3\n);\n\n\/\/ Here we utilize the hook variables to get our event, find the image, and echo the thumbnail.\nfunction my_action_add_event_featured_image( $file, $name, $template ) {\n  \/\/ Get the event for reference - we&#039;ll need it.\n  $event = $template-&gt;get(&#039;event&#039;);\n\n  $link = sprintf(\n    &#039;&lt;a href=&quot;%1$s&quot;&gt;%2$s&lt;\/a&gt;&#039;,\n    get_the_post_thumbnail_url( $event ),\n    get_the_post_thumbnail( $event, &#039;thumbnail&#039;, array( &#039;class&#039; =&gt; &#039;alignleft&#039; ) )\n  );\n\n  echo $link;\n}\n<\/pre><\/div>\n\n\n<p>This gives us the images just like we want:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"\/knowledgebase\/wp-content\/uploads\/2020\/11\/List_Widget_Filter_Images.png\" alt=\"\" class=\"wp-image-1948492\" style=\"width:608px;height:534px\"\/><figcaption class=\"wp-element-caption\">Hey, thumbnails! \ud83c\udf89<\/figcaption><\/figure>\n\n\n\n<p>There&#8217;s still a little styling to do there. For example, the thumbnail images are pushed right up against the event&#8217;s date and title. That&#8217;s nothing a little CSS in your theme&#8217;s stylesheet can&#8217;t handle.<\/p>\n\n\n\n<p class=\"has-text-color has-background\" style=\"color:#141827;background-color:var(--global-palette8)\">\u2139\ufe0f <strong>Related:<\/strong> <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/customizing-css\/\" target=\"_blank\" rel=\"noreferrer noopener\">Customizing CSS<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-the-custom-template-way\">The Custom Template Way<\/h4>\n\n\n\n<p>This approach is similar to the previous one, but we&#8217;re going to be a bit neater about where we put our HTML. What we&#8217;re doing is creating a custom template that contains the featured image, goes in the theme folder, and gets injected into the widget.<\/p>\n\n\n\n<p>Follow that? Yeah, not exactly &#8220;nice and neat&#8221; but it is a very effective and clean approach to get the featured image thumbnail in the widget. It also proWides more room to add logic without creating a giant function to handle it like the previous approach.<\/p>\n\n\n\n<p>First we use the <code>add_action<\/code> as we did before at the end of the <code>functions.php<\/code> file. This is hooking into the action that injects the template containing the event&#8217;s date and time and tells the theme to run a custom <code>my_action_add_event_featured_image<\/code> action.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n\/\/ Here we hook into our template action - just before the date tag, which is the first item in the container.\nadd_action(\n  &#039;tribe_template_after_include:events\/v2\/widgets\/widget-events-list\/event\/date-tag&#039;,\n  &#039;my_action_add_event_featured_image&#039;,\n  15,\n  3\n);\n<\/pre><\/div>\n\n\n<p>Now let&#8217;s define that function, again, in the <code>functions.php<\/code> file, right after the previous snippet.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nfunction my_action_add_event_featured_image( $file, $name, $template ) {\n\t\/\/ Get the event for reference - we&#039;ll need it.\n\t$event = $template-&gt;get(&#039;event&#039;);\n\n\t\/\/ Here&#039;s where we get and display our image.\n}\n<\/pre><\/div>\n\n\n<p>In the &#8220;nice and neat&#8221; approach, we used a similar snippet to inject the HTML for the featured image thumbnail. This time, we&#8217;re going to inject a custom template that contains that HTML. That way, you can always add more markup to the file instead of having to mess with your functions.<\/p>\n\n\n\n<p>We don&#8217;t need to create a template from scratch. There&#8217;s already a template in the plugin that contains the event&#8217;s featured image. It&#8217;s located in The Events Calendar plugin files, which is in the <code>wp-content<\/code> directory one level up from the theme folder. This is the file we want: <code>the-events-calendar\/src\/views\/v2\/list\/featured-image.php<\/code>.<\/p>\n\n\n\n<p>Let&#8217;s copy that <code>featured-image.php<\/code> file and put the copy in the theme folder. It&#8217;s not terribly important where the copied file goes, but it&#8217;s best that it lives in a <code>tribe<\/code> folder so it&#8217;s separated from the rest of the theme files. This would make a good path because it conforms to <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/customizing-template-files-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">the same pattern used for template overrides<\/a>: <code>[my-theme]\/tribe\/events\/v2\/widgets\/widget-events-list\/event\/featured_image.php<\/code>.<\/p>\n\n\n\n<p>So, going back to the <code>functions.php<\/code> file in the theme, we can add that path to our function, like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nfunction my_action_add_event_featured_image( $file, $name, $template ) {\n  $template-&gt;template( &#039;widgets\/widget-events-list\/event\/featured_image&#039;, $template-&gt;get_values() );\n}\n<\/pre><\/div>\n\n\n<p>There&#8217;s some sleight-of-hand happening here. See that <code>$template-&gt;get_values()<\/code> bit in the function? That makes sure the template values all get passed along to our new template.<\/p>\n\n\n\n<p>Here&#8217;s what we get:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"\/knowledgebase\/wp-content\/uploads\/2020\/11\/List_Widget_Images_Template_1-1.png\" alt=\"\" class=\"wp-image-1948495\" style=\"width:300px;height:431px\"\/><figcaption class=\"wp-element-caption\">This is a good start, but it still needs a little CSS to to style things, just like the first approach.<\/figcaption><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"\/knowledgebase\/wp-content\/uploads\/2020\/11\/List_Widget_Images_Template_5-734x1024.png\" alt=\"\" class=\"wp-image-1948494\" style=\"width:367px;height:512px\"\/><figcaption class=\"wp-element-caption\">A little CSS goes a long way!<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-the-template-override-way\">The Template Override Way<\/h4>\n\n\n\n<p>We have one more approach, and it&#8217;s a bit less work and messing with the <code>functions.php<\/code> file. Instead of creating our own template, we&#8217;re just going to override the plugin&#8217;s template. There&#8217;s an entire article on <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/customizing-template-files-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">template overrides and how they work<\/a>, but let&#8217;s quickly walk through it.<\/p>\n\n\n\n<p>First, locate the template we want to override. It&#8217;s located in the plugin folder itself, which is at <code>wp-content\/plugins\/the-events-calendar<\/code>. Once in there, let&#8217;s snag the actual file called <code>event.php<\/code> in the <br><code>\/src\/views\/v2\/widgets\/widget-events-list<\/code> folder.<\/p>\n\n\n\n<p>Now that we know where the template is, we can make a copy of it and add it to the active theme. We need to create a <code>\/tribe<\/code> folder in the theme, then drop the copied <code>event.php<\/code> file in there in another set of folders. The final file path of the copied template will be:\\<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwp-content\/themes\/&#x5B;your-child-theme]\/tribe\/events\/v2\/widgets\/widget-events-list\/event.php\n<\/pre><\/div>\n\n\n<p>Now that the files is in our theme, we can customize it to suit our needs! In this case, we can add the following line of code to the template to display the features image:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php echo tribe_event_featured_image( $event-&gt;ID, &#039;thumbnail&#039; ); ?&gt;\n<\/pre><\/div>\n\n\n<p>To display the featured image above or below the title, add it above or below this line, respectively:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php $this-&gt;template( &#039;widgets\/widget-events-list\/event\/title&#039;, &#x5B; &#039;event&#039; =&gt; $event ] ); ?&gt;\n<\/pre><\/div>\n\n\n<p>Or, if we want things to work look and work like the first two approaches, add that code after this line instead:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php $this-&gt;template( &#039;widgets\/widget-events-list\/event\/date-tag&#039;, &#x5B; &#039;event&#039; =&gt; $event ] ); ?&gt;\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\" id=\"h-wrapping-up\">Wrapping up<\/h4>\n\n\n\n<p>And there you have it \u2014 three solid approaches for adding an event&#8217;s featured image thumbnail to the event list widget. The first approach is &#8220;nice and neat&#8221; because it only involves working on one file. But the custom template approach offers more flexibility when it comes to adding more markup as well as better separation of concerns as the markup is kept distinct from the function that injects it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re going to go over the Events List Widget in this tutorial, including how to configure it, things to expect from it, and perhaps some tips and tricks you can use at your next cocktail party. You&#8217;ll be the star of the show, for sure. Adding the Widget to a Sidebar The first thing to&#8230;<\/p>\n","protected":false},"author":3,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[114],"tags":[105],"stellar-product-taxonomy":[158,161],"class_list":["post-1896551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-calendar-widgets","tag-widgets","stellar-product-taxonomy-events-calendar-pro","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":114,"label":"Calendar Widgets"}],"post_tag":[{"value":105,"label":"Widgets"}],"stellar-product-taxonomy":[{"value":158,"label":"Events Calendar Pro"},{"value":161,"label":"The Events Calendar"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Jaime Marchwinski","author_link":"https:\/\/theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":114,"name":"Calendar Widgets","slug":"calendar-widgets","term_group":0,"term_taxonomy_id":114,"taxonomy":"category","description":"","parent":61,"count":9,"filter":"raw","term_order":"0","cat_ID":114,"category_count":9,"category_description":"","cat_name":"Calendar Widgets","category_nicename":"calendar-widgets","category_parent":61}],"tag_info":[{"term_id":105,"name":"Widgets","slug":"widgets","term_group":0,"term_taxonomy_id":105,"taxonomy":"post_tag","description":"","parent":0,"count":10,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1896551"}],"version-history":[{"count":16,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896551\/revisions"}],"predecessor-version":[{"id":1968974,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896551\/revisions\/1968974"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1896551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1896551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1896551"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1896551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}