CMS Development

robmenger
Participant

Exclude topic from listing page and contain 10 posts per page

Currently I am trying to filter out posts from the listing page which contains topic News. At the moment I can filter these posts, but it only deletes the posts from the listing page. So when I have 10 posts per page and 2 posts contains the topic News, only 8 posts wil appear on the page.

 

So my question is: Is it possible to get posts from the next page? I try to have 10 posts on each page.

0 Upvotes
8 Replies 8
dennisedson
HubSpot Product Team
HubSpot Product Team

Exclude topic from listing page and contain 10 posts per page

how are you filtering?

does this work?

{% for content in contents %}
  {% for topic in content.topic_list %}
    {% if topic.name != "News" %}
	<p> Does not have the news topic</p>                  
    {% endif %}
  {% endfor %}
{% endfor %}

substitue the <p> for your listing post content layout

robmenger
Participant

Exclude topic from listing page and contain 10 posts per page

Hi @dennisedson!

 

Currently I am filtering this way:

 

{% for content in contents %}
	{% set hasBadTopic == "false" %}
	{% for topic in content.topic_list %}
  		{% if loop.first %}
    			{% set hasBadTopic = false %}
    		{% endif %}

    		{% if topic.name == "News" %}
    			{% set hasBadTopic = true %}
    		{% endif %}

   	 	{% if loop.last and hasBadTopic == false %}
    			<h4>{{ content.name }}</h4>
    		{% endif %}
  	{% endfor %}
{% endfor %}

You made a preview with the code above: https://app.hubspot.com/design-previewer/3793158/templates/6339052352

 

I'll check out if the code you sent me works. Thank you!

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Exclude topic from listing page and contain 10 posts per page

curious to know solution.  let us know if you figure it out

ps: unable to preview code as am not a member of that group 🙂

0 Upvotes
robmenger
Participant

Exclude topic from listing page and contain 10 posts per page

I made a screenshot of the preview page. I made 3 sections. The first section is a summary of how many posts we have, which topics we are using and all the posts with all the topics. In the second section I filtered out the posts which contains the "bad topic". In the last section I added the code I got from @Dennis_. 

 

screencapture-app-hubspot-design-previewer-3793158-templates-6339052352-2018-10-25-08_36_48.png

0 Upvotes
roisinkirby
HubSpot Product Team
HubSpot Product Team

Exclude topic from listing page and contain 10 posts per page

Hey @robmenger thanks for your question - could you please share a link to your blog for further context?

@dennisedson@Anton@Yoshi is this something you have any knowledge on / experience with? Thank you!

0 Upvotes
Yoshi
HubSpot Employee
HubSpot Employee

Exclude topic from listing page and contain 10 posts per page

Hey @robmenger , and @roisinkirby

I see where you come from, and I do not think there is a way to exclude specific topics from listing page. 

The workaround I can think of is creating a new blog (https://knowledge.hubspot.com/articles/kcs_article/cos-blog/cos-blog-how-do-i-create-a-cos-blog) that contains only "news" and manage separately. 

 

The goal that @robmenger trying to achieve seems uncommon, so may I know what is the good use case here? 

プロフェッショナルサービス


栁澤啓明|シニアテクニカルコンサルタント

robmenger
Participant

Exclude topic from listing page and contain 10 posts per page

Hi @roisinkirby!

 

The URL is https://blog.robinhq.com/

 

As you can see the first page contains 6 posts, becaus 4 of the 10 posts contain topic News. I would like to have 10 posts on each page. 

 

Page 3 contains 3 posts instead of 10.

Page 5 is empty, because all the posts on that page contains topic News.

 

Thanks you!

fmsthird
Member

Exclude topic from listing page and contain 10 posts per page

@robmenger  did you ever figure this out? I'm on the same situation 

0 Upvotes