{"id":1730449,"date":"2020-09-15T12:47:44","date_gmt":"2020-09-15T12:47:44","guid":{"rendered":"https:\/\/toolset.com\/?post_type=course-lesson&#038;p=1730449"},"modified":"2021-01-26T15:58:19","modified_gmt":"2021-01-26T15:58:19","slug":"displaying-related-posts","status":"publish","type":"course-lesson","link":"https:\/\/toolset.com\/es\/course-lesson\/displaying-related-posts\/","title":{"rendered":"Displaying Related Posts"},"content":{"rendered":"\n<p>There are two ways to display related posts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Display a list of the &#8220;many&#8221; related posts in both one-to-many and many-to-many relationships.<\/li><li>In one-to-many relationships, display fields that belong to the &#8220;one&#8221; side.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"displaying-many-related-items\">Displaying many related items<\/h2>\n\n\n\n<p>In Toolset, every time you need to display a list of items, you should use a <a href=\"https:\/\/toolset.com\/es\/glossary\/view\/\">View<\/a>. This includes displaying &#8220;many&#8221; related items. You should use this in two cases:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>When displaying a list of items (the &#8220;many&#8221; side) in a one-to-many relationship<\/li><li>When displaying related items in a many-to-many relationship<\/li><\/ul>\n\n\n\n<p>In our example, events have many speakers, so we&#8217;ll use a View to display them.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Create or edit a Content Template used to display events.<\/li><li>Insert a&nbsp;<strong>View<\/strong>&nbsp;block and create a new View.<\/li><li>Select to display the post type you need (i.e. speakers) and then select the option to display posts related to the current post.<\/li><li>Use blocks to design the output for your View. Because the View is already set to display related posts you don&#8217;t need to select the relationship in blocks you use to display dynamic content.<\/li><\/ol>\n\n\n\n<div class=\"wp-block-toolset-blocks-grid tb-grid\" data-toolset-blocks-grid=\"3d9c399fe625e1b972f817a0680229f6\">\n<div class=\"wp-block-toolset-blocks-grid-column tb-grid-column tb-grid-align-top\" data-toolset-blocks-grid-column=\"3034fbe886c11054e95b46b09d3e4112\">\n<figure class=\"wp-block-image tb-image tb-image-media\" data-toolset-blocks-image=\"a65981434963474117f80bc003576f10\"><div class=\"tb-image-polaroid\"><div class=\"tb-image-polaroid-inner\"><a href=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-500x422.png\" alt=\"\" class=\"wp-image-1770591\"\/><\/a><div class=\"tb-image-caption\"><figcaption>Selecting related posts to display with a View<\/figcaption><\/div><\/div><div class=\"tb-image-polaroid-shadow\"> <\/div><\/div><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-toolset-blocks-grid-column tb-grid-column tb-grid-align-top\" data-toolset-blocks-grid-column=\"3034fbe886c11054e95b46b09d3e4112\">\n<figure class=\"wp-block-image tb-image tb-image-media\" data-toolset-blocks-image=\"0c86e49790f27400674baa52cdd92634\"><div class=\"tb-image-polaroid\"><div class=\"tb-image-polaroid-inner\"><a href=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks.png\"><img decoding=\"async\" width=\"1741\" height=\"931\" loading=\"lazy\" src=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks.png\" alt=\"\" class=\"wp-image-1770609\" srcset=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks.png 1741w, https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks-300x160.png 300w, https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks-1024x548.png 1024w, https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks-150x80.png 150w, https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks-768x411.png 768w, https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks-1536x821.png 1536w, https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks-805x430.png 805w, https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-view-displaying-related-posts-with-toolset-blocks-840x450.png 840w\" sizes=\"auto, (max-width: 1741px) 100vw, 1741px\" \/><\/a><div class=\"tb-image-caption\"><figcaption>Displaying dynamic fields inside the View that lists related posts<\/figcaption><\/div><\/div><div class=\"tb-image-polaroid-shadow\"> <\/div><\/div><\/figure>\n<\/div>\n<\/div>\n\n\n\n<div class=\"tb-fields-and-text\" data-toolset-blocks-fields-and-text=\"794ce4be4e7153e48476b5bcc247aacc\"><p>When you are designing a View for related content, in a <a href=\"https:\/\/toolset.com\/es\/course-lesson\/many-to-many-post-relationships\/\">many-to-many relationship<\/a>, you may also want to display fields that belong to the relationship.<\/p><\/div>\n\n\n\n<p>To do this, add Toolset blocks to the View and use the <strong>Post Source<\/strong> to select the relationship (only available if you&#8217;ve added custom fields to the relationship in question). Then, choose the field to display.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Displaying one related item (parent)<\/h2>\n\n\n\n<p>When we say \u201cone\u201d, we mean items that are connected as \u201cone-to-many\u201d and are on the \u201cone\u201d side.<\/p>\n\n\n\n<p>For example, a venue can have many events, but each event belongs to only one venue. When displaying a single event, you can display information about its venue.<\/p>\n\n\n\n<p>Here&#8217;s a short video that explains the steps:<\/p>\n\n\n\n<div class=\"video-entry\">\n\t\t\t\t\t<div id=\"video-box-11_04_Displaying_one_related_parent_post\" style=\"display:none;\">\n                            <video id=\"video-src\" src=\"\/wp-content\/uploads\/videos\/11_04_Displaying_one_related_parent_post.mp4\" controls=\"\" controlslist=\"nodownload\" width=\"800\" height=\"450\"><\/video>\n                        <\/div>\n                        <div class=\"preview-video\">\n                            <a id=\"video-link\" href=\"#video-box-11_04_Displaying_one_related_parent_post\" class=\"wplightbox tour-video video-link\" data-width=\"800\" data-height=\"450\">\n\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item-1024x576.png\" class=\"img-responsive wp-post-image\" alt=\"\" loading=\"lazy\" srcset=\"https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item-1024x576.png 1024w, https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item-300x169.png 300w, https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item-150x84.png 150w, https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item-768x432.png 768w, https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item-1536x864.png 1536w, https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item-805x453.png 805w, https:\/\/toolset.com\/wp-content\/uploads\/2021\/01\/toolset-displaying-one-related-parent-item.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\">                                <img decoding=\"async\" class=\"icon-play img-svg\" src=\"https:\/\/toolset.com\/wp-content\/themes\/wp-types-bootstrap-theme\/img\/svg\/training\/play.svg\" width=\"58\" height=\"58\" alt=\"\">\n                            <\/a>\n                            <div class=\"preview-video__duration\">\n\t                                Duration <time>2:17<\/time>\n                             <\/div>\n                  <\/div>\n<\/div>\n\n\n\n<div class=\"tb-fields-and-text\" data-toolset-blocks-fields-and-text=\"93f624518bc4518471f30bde1ee4b77e\"><p><span>Use the following steps to display one related (parent) item:<\/span><\/p><\/div>\n\n\n\n<ol class=\"wp-block-list\"><li>Edit the Content Template for displaying the &#8220;many&#8221; side of the relationship (i.e. the template for &#8220;events&#8221;).<\/li><li>You can use any Toolset block to display parent information.<\/li><li>In the block properties, select the parent from <strong>Post Source<\/strong>.<\/li><li>Select the field you would like to display.<\/li><\/ol>\n\n\n\n<p>You just added the venue&#8217;s details to the Content Template for events!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\" tb-image tb-image-media aligncenter\" data-toolset-blocks-image=\"1dfbf0b939def5d08fac735f77820c08\"><a href=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-displaying-dynamic-fields-from-parent-posts.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/toolset.com\/wp-content\/uploads\/2020\/09\/toolset-displaying-dynamic-fields-from-parent-posts-500x270.png\" alt=\"\" class=\"wp-image-1770657\"\/><\/a><div class=\"tb-image-caption\"><figcaption>Selecting to display information from a parent post<\/figcaption><\/div><\/figure>\n<\/div>","protected":false},"author":4341,"featured_media":1890591,"template":"","related-lesson":[8469],"class_list":["post-1730449","course-lesson","type-course-lesson","status-publish","has-post-thumbnail","hentry","related-lesson-post-relationships"],"_links":{"self":[{"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/course-lesson\/1730449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/course-lesson"}],"about":[{"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/types\/course-lesson"}],"author":[{"embeddable":true,"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/users\/4341"}],"version-history":[{"count":8,"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/course-lesson\/1730449\/revisions"}],"predecessor-version":[{"id":1917933,"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/course-lesson\/1730449\/revisions\/1917933"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/media\/1890591"}],"wp:attachment":[{"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/media?parent=1730449"}],"wp:term":[{"taxonomy":"related-lesson","embeddable":true,"href":"https:\/\/toolset.com\/es\/wp-json\/wp\/v2\/related-lesson?post=1730449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}