{"id":1896506,"date":"2019-10-18T13:19:18","date_gmt":"2019-10-18T17:19:18","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/add-event-content-to-an-event-widget-2\/"},"modified":"2024-10-23T15:10:00","modified_gmt":"2024-10-23T19:10:00","slug":"add-event-content-to-an-event-widget","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/add-event-content-to-an-event-widget\/","title":{"rendered":"Include Event Content in the Events Calendar Widget"},"content":{"rendered":"\n\n\n<p>One customization request we&#8217;ve seen come up regularly is how to add post content to the <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/events-calendar-widgets\/\">Events Calendar widget<\/a>. Here we&#8217;ll take a look at how to do just that.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-the-scenario\">The Scenario<\/h4>\n\n\n\n<p>Let&#8217;s say we have placed the&nbsp;Events Calendar widget in the sidebar of a page. We can expect to see a lot of information about our events, including the dates, times, location, and more, depending on our widget settings.<\/p>\n\n\n\n<p>That&#8217;s nice and dandy, but what if we want to include a little more information about our events? Specifically, let&#8217;s find a way to add the event&#8217;s excerpt below the dates.<\/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<h4 class=\"wp-block-heading\" id=\"h-before\">Before:<\/h4>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"673\" height=\"1024\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.51.54@2x-673x1024.png\" alt=\"\" class=\"wp-image-1963237\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.51.54@2x-673x1024.png 673w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.51.54@2x-197x300.png 197w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.51.54@2x-768x1168.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.51.54@2x.png 818w\" sizes=\"auto, (max-width: 673px) 100vw, 673px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h4 class=\"wp-block-heading\" id=\"h-after\">After: <\/h4>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"1024\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.53.58@2x-652x1024.png\" alt=\"\" class=\"wp-image-1963238\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.53.58@2x-652x1024.png 652w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.53.58@2x-191x300.png 191w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.53.58@2x-768x1206.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-12.53.58@2x.png 828w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-how-it-s-done\">How it&#8217;s Done<\/h4>\n\n\n\n<p>The key here is that we can use the default WordPress function for <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/the_excerpt\">the_excerpt()<\/a> to display content from the event directly in the widget. For this use case, we will be changing the mobile view templates, so please note that this will affect the widget <em>and<\/em> the mobile month view of your calendar. <\/p>\n\n\n\n<p>This will require a template override. If you&#8217;re new to overriding calendar templates, then it&#8217;s a good idea to check out our <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/themers-guide\/\">Themer&#8217;s Guide<\/a>, which will walk you through the process step-by-step. The basic idea is that we will be creating a copy of one of the plugin&#8217;s templates, then adding it to our theme files. This allows us to override the template without touching the core code of the plugin.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Make a copy of the Mobile View&#8217;s\u00a0<em>mobile-event.php<\/em> file.<\/strong> This is located in <code>plugins\/the-events-calendar\/src\/views\/v2\/month\/mobile-events\/mobile-day\/mobile-event.php<\/code>.<\/li>\n\n\n\n<li><strong>Make a new folder in your theme directory.<\/strong> Call it\u00a0<em>tribe<\/em>.<\/li>\n\n\n\n<li><strong>Make a new folder in that one.<\/strong> Call it\u00a0<em>events<\/em>.<\/li>\n\n\n\n<li><strong>Make a new folder in that one.<\/strong> Call it\u00a0<em>v2<\/em>.<\/li>\n\n\n\n<li><strong>Make a new folder in that one.<\/strong> Call it\u00a0month.<\/li>\n\n\n\n<li><strong>Make a new folder in that one.<\/strong> Call it\u00a0<em>mobile-events<\/em>.<\/li>\n\n\n\n<li><strong>Make one last new folder in that one.<\/strong> Call it\u00a0<em>mobile-day<\/em>.<\/li>\n\n\n\n<li><strong>Add the file.<\/strong> Drop the copied\u00a0<em>mobile-event.php<\/em> file in that last folder.<\/li>\n<\/ul>\n\n\n\n<p>Presto! Now that the template is in our theme directory, we can modify to suit our needs. In this case, we will add this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php the_excerpt(); ?><\/code><\/pre>\n\n\n\n<p>&#8230;right below the single event cost. As of this writing, that is after Line 30 of the template.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"226\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-13.06.14-1024x226.png\" alt=\"\" class=\"wp-image-1963239\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-13.06.14-1024x226.png 1024w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-13.06.14-300x66.png 300w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-13.06.14-768x170.png 768w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2019\/10\/CleanShot-2024-10-23-at-13.06.14.png 1186w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Note &#8211; we have added some italics, but you can style this however you see fit. Now, we can save our work, head back to our widget and see the event&#8217;s excerpt displays with the rest of the event&#8217;s information. Nice work!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One customization request we&#8217;ve seen come up regularly is how to add post content to the Events Calendar widget. Here we&#8217;ll take a look at how to do just that. The Scenario Let&#8217;s say we have placed the&nbsp;Events Calendar widget in the sidebar of a page. We can expect to see a lot of information&#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":[1],"tags":[25,58,105],"stellar-product-taxonomy":[158],"class_list":["post-1896506","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-customizations","tag-php","tag-widgets","stellar-product-taxonomy-events-calendar-pro"],"acf":[],"taxonomy_info":{"category":[{"value":1,"label":"Uncategorized"}],"post_tag":[{"value":25,"label":"Customizations"},{"value":58,"label":"PHP"},{"value":105,"label":"Widgets"}],"stellar-product-taxonomy":[{"value":158,"label":"Events Calendar Pro"}]},"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:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":1,"name":"Uncategorized","slug":"uncategorized","term_group":0,"term_taxonomy_id":1,"taxonomy":"category","description":"","parent":0,"count":139,"filter":"raw","term_order":"0","cat_ID":1,"category_count":139,"category_description":"","cat_name":"Uncategorized","category_nicename":"uncategorized","category_parent":0}],"tag_info":[{"term_id":25,"name":"Customizations","slug":"customizations","term_group":0,"term_taxonomy_id":25,"taxonomy":"post_tag","description":"","parent":0,"count":177,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":128,"filter":"raw","term_order":"0"},{"term_id":105,"name":"Widgets","slug":"widgets","term_group":0,"term_taxonomy_id":105,"taxonomy":"post_tag","description":"","parent":0,"count":16,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1896506"}],"version-history":[{"count":3,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896506\/revisions"}],"predecessor-version":[{"id":1963242,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896506\/revisions\/1963242"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1896506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1896506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1896506"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1896506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}