<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add custom fields to blog posts in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/923780#M37917</link>
    <description>&lt;P&gt;&lt;A href="https://webocreation.com/hubspot-how-to-add-a-custom-field-in-the-hubspot-blog-post-and-listing-template/" target="_blank" rel="noopener"&gt;https://webocreation.com/hubspot-how-to-add-a-custom-field-in-the-hubspot-blog-post-and-listing-template/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2024 04:37:15 GMT</pubDate>
    <dc:creator>rupaknepali</dc:creator>
    <dc:date>2024-02-16T04:37:15Z</dc:date>
    <item>
      <title>Add custom fields to blog posts</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/426494#M22341</link>
      <description>&lt;P&gt;I would like to add custom fields to a blog post, for example a checkbox called "Featured Post". Then i would like to have access to this data within hubl code, so i can apply logic in the template&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 18:32:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/426494#M22341</guid>
      <dc:creator>Demetri</dc:creator>
      <dc:date>2021-04-09T18:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Add custom fields to blog posts</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/426612#M22355</link>
      <description>Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/180746"&gt;@Demetri&lt;/a&gt;,&lt;BR /&gt;Do you mean a checkbox for your team/customer who is creating the blog post per the visitors of the blog post who don't have access to hubspot?&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Anton</description>
      <pubDate>Sat, 10 Apr 2021 15:02:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/426612#M22355</guid>
      <dc:creator>Anton</dc:creator>
      <dc:date>2021-04-10T15:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Add custom fields to blog posts</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/426830#M22371</link>
      <description>&lt;P&gt;The people creating the blog post.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 12:55:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/426830#M22371</guid>
      <dc:creator>Demetri</dc:creator>
      <dc:date>2021-04-12T12:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Add custom fields to blog posts</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/427533#M22441</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/180746"&gt;@Demetri&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;okay - that's much easier to do &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have multiple options:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;create an if-loop inside the blog-post template and wrap it around the featured post code. By doing so the author will get an option("module") when creating a new post.&lt;/LI&gt;
&lt;LI&gt;create a new module with an if-loop and the featured post code. Personally I go almost always this way because it gives you much more flexibility(you could even show a featured post from another blog if you have mutliple ones). After creating this module you place the module where you want to show the optional featured post.&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here some code examples for both solutions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if-loop directly in template&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% boolean "show_featured_post" label='Show Featured post', value=True, export_to_template_context=True %}
...
{% if widget_data.show_featured_post %}
   place your featured post code here
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;place this code inside your blog-post(not listing) template. The if-loop should be in the place you would like to show the featured post.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if-loop in module and template&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;module&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% if module.show_featured_post %}
place your code here
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;template&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;...
{% module 'Featured Post' src="PATH-TO-MODULE", no_wrapper=True %}
...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;for the "easiest" use I would recommend to right-click the module in the left sidebar of the design-manager and select "Copy snippet". Place it in the template where you'd like to display the module. Also I recommend to add the no_wrapper=True option at the end of the module. This will minimize the sourcecode slightly by not using unneeded wrapping divs&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anton&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 20:17:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/427533#M22441</guid>
      <dc:creator>Anton</dc:creator>
      <dc:date>2021-04-13T20:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Add custom fields to blog posts</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/668936#M29665</link>
      <description>&lt;P&gt;How do you bring the custom fields to the listing view? It used to work but it no longer does.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 13:42:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/668936#M29665</guid>
      <dc:creator>adriancblack</dc:creator>
      <dc:date>2022-07-21T13:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Add custom fields to blog posts</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/923780#M37917</link>
      <description>&lt;P&gt;&lt;A href="https://webocreation.com/hubspot-how-to-add-a-custom-field-in-the-hubspot-blog-post-and-listing-template/" target="_blank" rel="noopener"&gt;https://webocreation.com/hubspot-how-to-add-a-custom-field-in-the-hubspot-blog-post-and-listing-template/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 04:37:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/923780#M37917</guid>
      <dc:creator>rupaknepali</dc:creator>
      <dc:date>2024-02-16T04:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Add custom fields to blog posts</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/1037160#M40571</link>
      <description>&lt;P&gt;Hope this helps someone in the future as there are still considerable gaps in the documentation regarding this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your listing loop, your data in the fields are stored in the module ID... so if your module snippet in the blog post is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% module "module_55555555555" path="/THEME/modules/CUSTOM MODULE", label="CUSTOM MODULE" %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then your loop would be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% for content in contents %} 
  {{ content.widgets.module_55555555555.value }}
{% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to see everything returned from the module you can just output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% for content in contents %} 
  {{ content.widgets.module_55555555555 }}
{% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my case, my module had 1 singular "Link" field type field called "external_link", so to get the URL I had to call:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% for content in contents %} 
  {{ content.widgets.module_55555555555.body.external_link.url.href }}
{% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and of course, to complicate things, Hubspot will return the content ID if the link is to content and the href if the link is external.&amp;nbsp; But you get the idea.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another thing to note is that you can see ALL custom fields in your blog listing loop by using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% for content in contents %} 
  {{ content.allWidgets }}
{% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, Hubspot, this should be in the docs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 19:05:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Add-custom-fields-to-blog-posts/m-p/1037160#M40571</guid>
      <dc:creator>squatchcreative</dc:creator>
      <dc:date>2024-09-05T19:05:08Z</dc:date>
    </item>
  </channel>
</rss>

