-
AuthorPosts
-
May 1, 2017 at 10:49 pm #786010
I have a membership plugin (WPMU Dev Membership 2) that restricts what posts are shown to the user. But when I use the Blog Posts element (shortcode) it just shows every post.
When I change to the default theme everything works. Meaning the posts on the home page are restricted to only the ones that should be shown.
Best I can tell, something in blog.php isn’t processing the query as expected to handle all the filters (pre_get_posts) from the plugin.
Any ideas?
May 2, 2017 at 8:14 am #786208Hey ahouglum,
You need to ask help to the WPMU plugin to check the compatibility with our theme.
Best regards,
John TorvikMay 2, 2017 at 5:52 pm #786584I ran a number of tests using query_posts like the below code and it always works just fine (I.E. filters the results to only show what the user has access to) As soon as I switch to your Blog Posts element it doesn’t work. I can’t find where, but it seems like your Blog Posts element (shortcode) doesn’t use the pre_get_posts filter?
In fact, the wordpress docs specifically say to NOT use the query_posts method.
Any suggestions would be appreciated.
add_action( 'wp_footer', function() { query_posts( 'posts_per_page=5' ); while ( have_posts() ) : the_post(); echo '<li>'; the_title(); echo '</li>'; endwhile; // Reset Query wp_reset_query(); } );
May 2, 2017 at 8:37 pm #786685Hi,
Please try the following
add_action( 'wp_footer', function() { // Reset Query wp_reset_query(); query_posts( 'posts_per_page=5' ); while ( have_posts() ) : the_post(); echo '<li>'; the_title(); echo '</li>'; endwhile; // Reset Query wp_reset_query(); } );
Lets see if we have to reset the query and we have something open.
Best regards,
BasilisMay 2, 2017 at 11:09 pm #786785I must not of explained myself very well. The code I put in works. I was just showing you that to prove that query_posts function normally works.
But, how blog.php and loop-index.php work together doesn’t allow for the filters. Or some other weirdness that doesn’t process the membership plugin.
Now when I use basic code, like what I pasted in, everything works. (or when using theme 2016).
So, there is something with the Blog Post shortcode that isn’t using standard processes.
WPMU DEV basically says that it works in 2016 and 2017 theme so it isn’t their problem.
May 3, 2017 at 9:06 pm #787401Hi,
Yea I guess that is because our filter is a bit different from what you are using at the web site.
Best regards,
BasilisMay 4, 2017 at 12:10 am #787479Yes, but that doesn’t really help me. I can’t turn it off. How can I ensure Enfold follows loop best practices so plugins can filter the loop normally?
May 4, 2017 at 10:50 pm #788107Hi,
The Enfold Loop filter
https://github.com/DevinVinson/enfold-child-docs/blob/master/includes/loop-index.phpPlease take a look here and let us know if it guides you at all.
Best regards,
BasilisMay 5, 2017 at 10:27 pm #788661Is this new code for loop-index.php? I knew were the loop code existed. I’m trying to find where in the Enfold code does it deviate from a “normal” loop.
As I dig into this issue some more. I believe the issue isn’t in the Blog Posts shortcode but in the loop itself.
Because when I look at just the category link that shows all the post in the category. Using Enfold the category page doesn’t filter the results. Switching to the 2016 theme. It filters just fine.
I would think this basic loop (category posts) would follow standard WP practices to other plugins can use filters.
May 7, 2017 at 8:20 pm #789167Hi,
What I have send you is a sample on how it can be customised and how it works.
We do use filteers and hooks but they are not the same as the 2016 theme.Best regards,
Basilis -
AuthorPosts
- You must be logged in to reply to this topic.