Skip Navigation

[Resolved] Latest post is missing in view on homepage but not same view in page or post

This support ticket is created 7 years, 6 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.

Our next available supporter will start replying to tickets in about 6.21 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 20 replies, has 2 voices.

Last updated by bobA-2 7 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#449430

I have a view which is inserted into theme index page (frontpage) template using <?php echo do_shortcode ('[wpv-view name="myviewname"]'); ?>

The most recent post is missing in the view. But the exact same view shows it correctly when it is on a Page or in a Post. So there must be an issue causing this when the view is on the frontpage?

It used to work on the frontpage showing all posts including the most recent. But it seems changes in WP-View after version 1.9 is the reason.

I have narrowed it down to the wp-views\embedded\inc\wpv-filter-post-types-embedded.php if I replace that file with the wpv-filter-post-types-embedded.php from WP-Views 1.9 the most recent post appears in the view again on the frontpage.

More specific it seems to be something in this code in wpv-filter-post-types-embedded.php

If I replace this part of the code in Views 2.2

global $wp_query;
            if ( isset( $wp_query->posts[0] ) ) {
                $current_post = $wp_query->posts[0];
                $post_not_in_list = $current_post ? array( $current_post->ID ) : array();
				if ( isset( $query['post__not_in'] ) ) {
					$query['post__not_in'] = array_merge( (array) $query['post__not_in'], $post_not_in_list );
				} else {
					$query['post__not_in'] = $post_not_in_list;
				}
            }
        } else {
			global $post;
			if ( $post instanceof WP_Post ) {
				$post_not_in_list = array( $post->ID );
				if ( isset( $query['post__not_in'] ) ) {
					$query['post__not_in'] = array_merge( (array) $query['post__not_in'], $post_not_in_list );
				} else {
					$query['post__not_in'] = $post_not_in_list;
				}
			}
		}
    }
    
    return $query;

with this code from Views 1.9 it works again

global $wp_query;
           if (isset($wp_query->posts[0])) {
                $current_post = $wp_query->posts[0];
                $post_not_in_list = $current_post ? array($current_post->ID) : array();
            
				if ( isset( $query['post__not_in'] ) ) {
					$query['post__not_in'] = array_merge( (array)$query['post__not_in'], $post_not_in_list );
				} else {
					$query['post__not_in'] = $post_not_in_list;
				}
           //     $query['post__not_in'] = $post_not_in_list;
            }
        } else if ( isset( $_GET['wpv_post_id'] ) ) { //in AJAX pagination is_single() and is_page() do not work as expected
			if ( isset( $query['post__not_in'] ) ) {
				$query['post__not_in'] = array_merge( (array)$query['post__not_in'], array( $_GET['wpv_post_id'] ) );
			} else {
	//			$query['post__not_in'] = array( $_GET['wpv_post_id'] );
			}
        }
    }
    
    return $query;

Should I need to do this edit of the code or is it an issue you can fix in coming versions?

#449849

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bob,

Thank you for contacting our support forum.

I don't think that this is an issue with the code itself but could be more configuration.

Would you mind providing me with admin access to the website so I can have a look ?

The private fields will be enabled for your next response.

Thanks,
Shane

#450667

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bob,

It could be caching issues since the view works on the other page you sent me.

Could you remove this view from the homepage and add it again.

Please let me know if this helps.
Thanks,
Shane

#450677

I have removed it and loaded the front page and added it again. No change. Do not think it is caching since making the code change I mentioned in my first post fixes it. You can try doing it perhaps and verify?

#450743

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bob,

Thats correct but since it works completely fine on another page even when the original code is there then I wouldnt suspect that it was this code that is causing the problem.

To ensure that its not a bug with the plugin could you temporarily disable your non-toolset plugins as well as switch your theme to a default on and try again.

This is just for testing purposes to see if the new post will show up.

Thanks,
Shane

#450856

I have disabled all plugins but types and views and installed Twenty Sixteen theme and edited the index.php of the theme to add the view <?php echo do_shortcode ('[wpv-view name="myviewname"]'); ?>

Still the difference is there, missing the latest post on the frontpage

#451095

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bob,

Could you try using this function to run the shortcode wpv_do_shortcode instead of do_shortcode.

Thanks,
Shane

#451103

I have changed the code into wpv_do_shortcode as requested. No change.

#451106

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bob,

Are you able to insert the shortcode directly onto the page without modifying the theme files ?

Is there an editor that you can place the shortcode in ?

Please let me know.
Thanks,
Shane

#451109

I have just inserted into the theme index.php (Twenty Sixteen theme) via the code editor. If I change the front page to show A static page (The page with the same View shortcode) the most recent post is shown. I have done that now as you perhaps can see.

There is not a editor in my regular theme for the front page no.

#451153

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bob,

So its just the latest post not showing like this ?

Also does the problem persist with the twenty sixteen theme when adding it using the do_shortcode ?

Reason why i'm asking because it could be a bug or a theme compatibility issue.

Looking forward to hearing from you soon.

Thanks,
Shane

#451265

I switched to Twenty Sixteen theme back in reply #450743 so yes the same issue with the theme with do shortcode. And it is only the latest post which is missing unless I do the code change stated in my first post.

So I can only conclude:

-not a plugin conflict
-not a theme issue

If there is no issues in doing the code change to the old View 1.9 wpv-filter-post-types-embedded.php code I can continue to do this with each Views update but seems strange that the newer Views versions has this problem for me does it not?

I thought about doing a discover-wp.com site test to see if I could replicate the problem there too but I do not think I can do a theme edit there to add the do shortcode to the frontpage.

I have been able to replicate the same problem on a different site I have. Any chance that you or one on your team can do a simple view test with theme insertion of do shortcode on the index / frontpage to see if you can replicate the problem?

#451541

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screen Shot 2016-10-28 at 2.56.40 PM.png
Screen Shot 2016-10-28 at 2.56.47 PM.png

Hi Bob,

I did a local test of this as well and noticed that I was not able to replicate the issue, see screenshot.

Could you recreate the view from scratch and let me know if the problem still continues ?

Since i'm not able to replicate on a fresh installation this means that there isn't a bug and could just be something wrong with the view itself.

Looking forward to hearing from you soon.

Thanks,
Shane

#451549

I have just done a fresh install of Types and Views on a third site of mine diffrent webserver too in fact.

1. Set up a simple view showing latest posts titled (Test 1, Test 2, Test 3)
2. Inserted the <?php echo do_shortcode('[wpv-view name="testview"]'); ?> inside the index of the Twenty Fifteen theme.

It is exactly the same issue only Test 1 and Test 2 is shown. The most recent post is missing so I am out of ideas if you cannot replicate it 🙁

If you have no other ideas I will just continue to do the code edit with the old Views 1.9. Let me know what you think.

#451565

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bob,

Would you mind providing me with the debug information for the site ?

This could point me to where the issue is.

To provide the debug information please have a look at the link below.
https://toolset.com/faq/provide-debug-information-faster-support/

Thanks,
Shane

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