Skip Navigation

[Resolved] Views does not show all posts

This support ticket is created 7 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 12 replies, has 2 voices.

Last updated by Nigel 7 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#467116

I am trying to add a view to an archive page. But it does not work correctly.

I have the following problems:
1) Not all posts are being showed.
2) Toolset Maps does not show the places for all posts
3) Infinite scroll does not work. But this is maybe a separate question.

Here is my link: hidden link

Pagination:
- Set to Pagination enabled with manual transition and AJAX
- Display 8 items
- Infinite scroll

Custom Search:
- AJAX results update when visitors change any filter values
- The search form and the results are being displayed

Filter Editor:

<div class="col-md-3">
  [wpv-filter-start hide="false"]
  [wpv-filter-controls]
  [wpml-string context="wpv-views"]Type[/wpml-string] [wpv-control field="type" url_param="fototype" type="checkboxes" auto_fill="wpcf-type" auto_fill_sort="asc"]
  
	[wpml-string context="wpv-views"]Årstid:[/wpml-string] [wpv-control field="arstid" url_param="arstid" type="radios" auto_fill="wpcf-arstid" auto_fill_sort="asc"]
  
	[wpv-filter-submit name="Søk" type="input"]

	[wpv-filter-reset reset_label="Nullstill" type="input"]
</div>

<div class="col-md-9">
  [wpv-filter-search-box]
</div>

[/wpv-filter-controls]
[wpv-filter-end]

Loop Output Editor:

<div class="col-md-9">
  	[wpv-layout-start]
	[wpv-items-found]
	[wpv-map-render map_id='map-3']
	<!-- wpv-loop-start -->
	<wpv-loop>	
      [wpv-map-marker map_id='map-3' marker_id='marker-[wpv-post-id]' marker_field='wpcf-address'][/wpv-map-marker]
	[wpv-post-body view_template="Loop item in Search - Bilder"]
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]       
</div>

Template for the view:

<div class="col-md-3 littmerluft">
  	<a href="[wpv-post-url]" class="displayblock" role="button" title="[wpv-post-title]" onmouseover="this.title='';">[wpv-post-title][wpv-post-featured-image]</a> 
</div>

When visiting the page (hidden link) you see 5 items. There are actually going to be 6. The last one is not visible.

On the map there are 2 adresses. This should be 5 or 6.

I hope you can understand this,

Any ideas how the problem could be solved?

Looking forward to hear from you again,

#467331

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Ole

Before digging too deep into this can I clarify the very first thing you state: "I am trying to add a view to an archive page".

An archive is a built-in WordPress concept and it returns all the posts of a given post type (subject to pagination settings).

If you have a custom post type with a slug of "projects" then the archive is available at "mysite.com/projects" without any special intervention on your part.

You can use Views to customise the archive—including adding custom search filters—at Toolset > WordPress Archives.

When you do so you can also insert related Views onto the archive page.

But I need to be clear about what you are doing/aiming to do here.

Are you working with the archive, or a view you are additionally adding to a custom archive page?

#467337

Hello,

You are correct, I have a custom post type with slug "bilde". The archive page can therefor be found at mydomain/bilde.

I added the archive by going from the Toolset Dashboard to press "Add archive layout" (or something similiar) to the custom post type.

All I am aiming to get the archive page up and running. The only things that should work at the moment are:
1) Show all posts. Currently the last one does not show
2) Toolset Maps should show all places for the posts. Currently it only shows 2. It should also show places that has not been loaded with infinite scroll.
3) Infinite scroll. But this is maybe a separate question, or maybe it will be solved when the problems above are solved.

Hope this helps,

Looking forward to hear from you again,

#467725

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Ole

1. You created an archive layout for your bilde post type from the dashboard.

What did you add to the layout, an archive cell, yes?

I went through the steps of doing that myself on a test site just now and all of the posts show.

Do you have any filters added that might exclude a result?

As a test can you edit the archive and remove the pagination and re-test to see whether the missing post is still missing?

2. The latter part of what you want here—that the map shows all posts while the list of results works via infinite scroll pagination—I would not expect to work. Pagination works along the lines of "fetch the posts on the 3rd page which would be posts 21-30". If the map is being added to the archive it is using the same query and has the same results available to it. You would need to create a separate view for the map independent of the archive and add it to the same page.

If some of the posts are absent from the map, the most likely explanation is that they are missing entries for the address custom field. Can you verify that they have an entry in the address field used by the map?

3. Can you clarify what you mean by infinite scroll doesn't work?

Naturally, there need to be enough items to scroll (you only have a few posts), and if you set the pagination to a small number for testing, bear in mind that infinite scroll requires a scroll event to be triggered, if there isn't enough content on your screen to go past the bottom of the viewport that you cannot scroll the page.

#467729

Thank you very much, that explains some of the problems.

I will look into this tonight, and give you feedback 🙂

Best regards,

#467736

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Great, no problem, let me know how you get on.

#467939

Hello again,

I will answer to all of the questions.

1. You created an archive layout for your bilde post type from the dashboard.

What did you add to the layout, an archive cell, yes?

I went through the steps of doing that myself on a test site just now and all of the posts show.

Do you have any filters added that might exclude a result?

As a test can you edit the archive and remove the pagination and re-test to see whether the missing post is still missing?

Answer: Tried without pagination and still does not work. The last one does not show up. I just added 3rd, 2nd and 1st. 3rd and 2nd shows up, but 1st is hidden. Please see: hidden link

I suspect there is something wrong with the following:

Filter editor:

   <div class="holder">
      <div class="col-md-3 ui grey padding">
         [wpv-filter-start hide="false"]
            [wpv-filter-controls]
               [wpml-string context="wpv-views"]<span class="list-header">Type</span>[/wpml-string] 
               [wpv-control field="type" url_param="fototype" type="checkboxes" auto_fill="wpcf-type" auto_fill_sort="asc"]
  
               <hr>
  
	      [wpml-string context="wpv-views"]<span class="list-header">Årstid:</span>[/wpml-string]
              [wpv-control field="arstid" url_param="arstid" type="radios" auto_fill="wpcf-arstid" auto_fill_sort="asc"]
    
              <hr>
    
              [wpv-post-taxonomy type='sted']
              [wpv-post-taxonomy type='category']
              [wpv-post-taxonomy type='post_tag']
  
              <hr>
  
	     [wpv-filter-submit name="Søk" type="input" class="btn-lg"]
	     [wpv-filter-reset reset_label="Nullstill" type="input" class="btn-lg"] 
  	
             <hr>
  
             Bestill flere bilder
 
<!-- Is something missing here? -->

         </div>

 <div class="col-md-9 ui littluft">
	[wpv-filter-search-box id="srch-inpt-box"]
	[wpv-filter-submit name="Søk" type="input" class="btn-lg"]
</div>

[/wpv-filter-controls]
[wpv-filter-end]
</div>

2. The latter part of what you want here—that the map shows all posts while the list of results works via infinite scroll pagination—I would not expect to work. Pagination works along the lines of "fetch the posts on the 3rd page which would be posts 21-30". If the map is being added to the archive it is using the same query and has the same results available to it. You would need to create a separate view for the map independent of the archive and add it to the same page.

If some of the posts are absent from the map, the most likely explanation is that they are missing entries for the address custom field. Can you verify that they have an entry in the address field used by the map?

Answer: Thank you, I suspected it was set up something like this. This is what I am going to achieve:

1) The archive page should show the first 6 posts, and then 6 more is added when scrolling.
2) To see the wanted posts as fast as possible the user should be able to click the map to sort out the posts. E.g when two posts are tagged at the same place, clicking the icons should make all the others dissapear. Or make the specific posts appear on the map, like this: hidden link
3) Therefor its important that the maps shows all the posts.

Note: I understand if the sorting out would not work, but is there a possibility to click on the map to show the posts? Right now the map does not have any function.

Right now all my 11 posts have either an adress (Trondheim, Norge) or coordinates ({63.401015752458854,10.42801178437503}). In Edit Post I can see the map show up with an icon. But only 3 of the posts shows up on the map on the archive page.

Any ideas?

3. Can you clarify what you mean by infinite scroll doesn't work?

Naturally, there need to be enough items to scroll (you only have a few posts), and if you set the pagination to a small number for testing, bear in mind that infinite scroll requires a scroll event to be triggered, if there isn't enough content on your screen to go past the bottom of the viewport that you cannot scroll the page.

Answer: There was a bug in my code. The problem is now solved.

Looking forward to hear from you again,

Best regards

#468292

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Ole

I'm still stuck on why one of your posts is missing, as I can't reproduce it on a test site.

I don't have any debug info for you (https://toolset.com/faq/provide-debug-information-faster-support/) to see what your set up is.

This needs testing on a default set-up, i.e. with twentysixteen and the integration plugin as you are using Layouts, but as there are a few things to check I think it would be easier if I checked them myself.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes other than possibly to temporarily add a backup plugin to take a snapshot of the site.

#469306

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Ole

I looked at your site and have a few observations.

Firstly, you are using Layouts but it appears your theme is not integrated with Layouts, hence the warning messages, and which means you may get unexpected results. (See https://toolset.com/documentation/user-guides/layouts-theme-integration/)

Secondly, the Layout which you have assigned to the Bilder archive doesn't include an archive cell.

You are effectively hijacking the url of the archive but not displaying the archive on that page and instead displaying two views. This is somewhat wasteful inasmuch as an archive query runs but is not used, but in any case explains why the latest post is always missing from your results. Your view has the option "Don't include current page in query result" checked. It is confused because it is on an archive page and the first result that would appear on the archive page (normally the most recent post) is treated as the current page and so is excluded from the view results.

If you check your site you will see that I created a new Layout "Archive Layout for Bilder" which I assigned to the Bilder archive (you can always re-assign your old archive), and I added an archive cell to that layout with a custom bilder archive with infinite scroll pagination.

If you visit the archive page you will see that the infinite scroll works as expected and that all results are returned. You can convert it to a custom search archive if you wish, and add a view for your map-based results. (See https://toolset.com/documentation/user-guides/display-on-google-maps/)

I did that on my test archive page so you can see what's involved, and it appears to be working.

But note that if you have several results with identical locations there is no way to isolate the individual markers no matter how far you zoom in.

#469525

Thank you Nigel for the patience and hospitality,

Firstly, you are using Layouts but it appears your theme is not integrated with Layouts, hence the warning messages, and which means you may get unexpected results. (See https://toolset.com/documentation/user-guides/layouts-theme-integration/)

Yes, it`s correct that the theme is not fully integrated with Layouts. However, for this Layouts is correctly integrated within the archive-page for the custom post type.

<?php get_header(); ?>

<div class="clearfix">
    <div class="holder">
    	<?php the_ddlayout('default-layout'); ?>
    </div>
</div>

<?php  get_sidebar(); get_footer(); ?>

So errors on backend may show up some places, but has no directly influence on the archive page. A layout for single posts has not been made yet, because I am not sure they should exist. The images on archive should maybe opened in lightbox, and single posts redirected to the archive page. This could be the best solution for the visitors. Layouts is also not integrated because some posts and pages has alot for php, which has not been converted into shortcodes. And what I have understood correctly, Types does not yet support php tags inside Views and so on.

Secondly, the Layout which you have assigned to the Bilder archive doesn't include an archive cell.

You are effectively hijacking the url of the archive but not displaying the archive on that page and instead displaying two views. This is somewhat wasteful inasmuch as an archive query runs but is not used, but in any case explains why the latest post is always missing from your results. Your view has the option "Don't include current page in query result" checked. It is confused because it is on an archive page and the first result that would appear on the archive page (normally the most recent post) is treated as the current page and so is excluded from the view results.

Oh, I understand. Sorry I am having a hard time learning the differentes between Views and Archive. No matter how much I have read, it`s hard for me to understand. I will keep on trying untill I have learned it 100%. But this clears something up.

If you check your site you will see that I created a new Layout "Archive Layout for Bilder" which I assigned to the Bilder archive (you can always re-assign your old archive), and I added an archive cell to that layout with a custom bilder archive with infinite scroll pagination.

Great, thank you very much. It looks so simple when you have made it.

If you visit the archive page you will see that the infinite scroll works as expected and that all results are returned. You can convert it to a custom search archive if you wish, and add a view for your map-based results. (See https://toolset.com/documentation/user-guides/display-on-google-maps/)

Superb, looks like its working very well. I will try to convert it into a custom search archive, and see how it works out.

I did that on my test archive page so you can see what's involved, and it appears to be working.

But note that if you have several results with identical locations there is no way to isolate the individual markers no matter how far you zoom in.
I see, I will try to figure this out.

I believe the problem is solved then, but one last question. Do you want me to open a new case if I get any more troubles, or want me to post here?

Best regards,

#469828

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Ole

Well, we have a one issue per thread policy on the forums, and your first post had 3 questions, so ¯\_(ツ)_/¯

If you have a follow-up question that directly relates to the above you can ask it here, but otherwise you might want to start a new thread, thanks.

For clarity...

A View is a generic query to return posts (or taxonomies, or users) that match certain criteria (your query filters). Where a View appears depends on where and how you add it.

An archive is not a Toolset concept, it is a WordPress concept. For a given post type it is just a list of all the posts of that type, normally in reverse chronological order. The 'blog' is just the archive of standard WordPress posts.

How do we know we are on an archive page? The url. By default if you have a custom post type with a slug of, say, project, then visiting mysite.com/project is interpreted by WordPress to mean show the archive of projects.

If you create a custom WordPress archive in Views then Toolset will take control of that archive and use your custom query to select the matching posts and output them according to your design in the loop output section.

If you now add Layouts in to the mix and assign a Layout to the archive then Layouts will take control of what appears at that url. It will display whatever you add to the Layout, even if it is just a text cell. To make the archive itself appear you need to add it with an archive cell.

#470370

Thank you for that brief explanation.

Please take a look at the page again: hidden link

I added the search field, and it turns out it just refreshes the page? Nothing happends?

Could it be because of the structure of my custom search?

I really want the filters to be on the left side with 3-columns width and the search bar at the top with 9-columns width.

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="holder">
	<div class="col-md-3 ui filterbox padding texttrans">
		[wpml-string context="wpv-views"]<span class="list-header">Type</span>[/wpml-string] [wpv-control field="type" url_param="fototype" type="checkboxes" auto_fill="wpcf-type" auto_fill_sort="asc"]
  
		<hr>
  
		[wpml-string context="wpv-views"]<span class="list-header">Årstid:</span>[/wpml-string] [wpv-control field="arstid" url_param="arstid" type="radios" auto_fill="wpcf-arstid" auto_fill_sort="asc"]

      	<hr>
      
      [wpml-string context="wpv-views"]Steder:[/wpml-string] [wpv-control taxonomy="sted" url_param="wpv-sted" type="checkboxes" taxonomy_order="ASC" taxonomy_orderby="name" hide_empty="false"]
      
      <hr>
  
		[wpv-filter-submit name="Søk" type="input" class="btn-lg search-trigger texttrans"]
		[wpv-filter-reset reset_label="Nullstill" type="input" class="btn-lg search-trigger texttrans"] 
  	
  		<hr>
  
 
    	<button type="button" class="btn texttrans" data-toggle="modal" data-target="#bestill" title="Bestill">Bestill flere bilder</button>
    
    	<div id="bestill" data-keyboard="true" class="modal fade" role="dialog" tabindex="-1">
  			<div class="modal-dialog">
    			<div class="modal-content">
      				<div class="modal-header">
        				<button type="button" class="close" data-dismiss="modal">&times;</button>
        				<h1 class="light nomargintop">Bestilling av bilder</h1>
      				</div>
     				<div class="modal-body">
      					<div class="sporsmal texttrans blacktext">
            				<h3 class="thin nomargintop centertext">Fyll ut skjemaet nedenfor, så tar jeg kontakt.</h3>     
                          <div class="sporsmal">
            				[contact-form-7 id="1359" title="Kontaktskjema_copy"]
                          </div>
            				<h3 class="luftvenstre thin bluelink orangehoverlink nomarginbottom">Meldingen blir sendt til <strong><a href="mailto:kontakt@vekvemedia.no" title="Send e-post til Vekve Media">kontakt@vekvemedia.no</a></strong></h3>
						</div>
     				</div>
      			<div class="modal-footer">
        			<button type="button" class="btn btn-default" data-dismiss="modal">Lukk</button>
      			</div>
    		</div>
		</div>
	</div>
  </div>
	<div class="col-md-9 ui littluft nomargintop">
  		<div class="search-field">
			[wpv-filter-search-box id="srch-inpt-box search-field"]
  			[wpv-filter-submit name="Søk" type="input" class="btn-lg search-trigger texttrans"]
		</div>
	</div>
</div>
[/wpv-filter-controls]
[wpv-filter-end]

Any ideas how this can be solved?

Looking forward to hear from you again Nigel,

#470545

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screen Shot 2016-12-23 at 11.46.21.png

Hi Ole

Please see this screenshot from when I edited your search archive.

Somehow you had added the search box without it creating the search filter (that you will now see in the Query Filter section).

I pressed the button to fix it and try a test search and it seems to work now.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.