Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

BlogTagSearch shows unpublished posts as a result #21

Open
kealsera opened this issue Jun 11, 2017 · 1 comment
Open

BlogTagSearch shows unpublished posts as a result #21

kealsera opened this issue Jun 11, 2017 · 1 comment

Comments

@kealsera
Copy link

kealsera commented Jun 11, 2017

If you search for a certain tag posts which aren't published yet (or are scheduled to be published in the future) will show up in the BlogTagSearch Results.

That's my markup for the tagsearch page:

   <h3>  Search by tag <strong>{{ blogTagSearch.tag.name }}</strong> </h3>
   {% for post in blogTagSearch.posts %}
   <div class="entry clearfix wow zoomIn post type-post status-publish format-standard has-post-thumbnail sticky hentry">
      <!-- Post Title -->
      <h3 class="entry-title">
         <a href="{{ post.url }}">{{ post.title }}</a>
      </h3>
      <!-- Small Image Left, Excerpt Right -->
      <div class="entry-image entry-image-left">
         <a class="post-thumbnail post-thumbnail-small" href="{{ post.url }}">
         <img
            src="{{ post.featured_images.first().getThumb(1200, 676, 'crop') }}"
            class="attachment-full size-full wp-post-image"
            alt="{{ post.title }}"
            title="Click for {{ post.title }}" />
         </a>
      </div>
      <div class="entry-content-right">
         {{ post.summary | raw }}
      </div>
      <!-- /Small Image Left, Excerpt Right -->
      <!-- Post Meta -->
      <div class="entry-meta entry-meta-right">
         <i class="fa fa-calendar" aria-hidden="true"></i> {{ post.published_at|date('M d, Y') }}<br /> {% if post.categories.count
         %} {% for category in post.categories %}
         <a href="{{ category.url }}" rel="category tag"><i class="fa fa-tag" aria-hidden="true"></i> {{ category.name }}</a>{%
         if not loop.last %}, {% endif %} {% endfor %} {% endif %}
      </div>
      <!-- /Post Meta -->
   </div>
   {% else %}
   <p class="text-center">{{ noPostsMessage }}</p>
   {% endfor %} {% if posts.lastPage > 1 %}
   <div class="posts-pagination">
      <div class="posts-pagination-block">
         {% if posts.currentPage > 1 %}
         <a href="{{ this.page.baseFileName|page({ (pageParam): (posts.currentPage-1) }) }}"><span class="ic ic-angle-left"></span></a>            {% endif %} {# for page in 1..posts.lastPage
         <a href="{{ this.page.baseFileName|page({ (pageParam): page }) }}" class="{{ posts.currentPage == page ? 'active' : null }}">
         {{ page }}
         </a> endfor #} {% if posts.lastPage > posts.currentPage %}
         <a href="{{ this.page.baseFileName|page({ (pageParam): (posts.currentPage+1) }) }}"><span class="ic ic-angle-right"></span></a>            {% endif %}
      </div>
   </div>
   {% endif %} {% partial "blog/pagination"%}
</div>
<div class="col-md-3 sidebar">
   {% partial 'modules/sidebar' %}
</div>

I (temporarily) fixed it by adding filter for the post being published & date not being in the future.

{%if post.published ==1 and (post.published_at ) < date()%}

@GinoPane
Copy link

@kealsera Actually it is considered as a "feature": rainlab/blog-plugin#370

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants