Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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?

    #786208

    Hey ahouglum,

    You need to ask help to the WPMU plugin to check the compatibility with our theme.

    Best regards,
    John Torvik

    #786584

    I 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();
    } );
    #786685

    Hi,

    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,
    Basilis

    #786785

    I 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.

    #787401

    Hi,

    Yea I guess that is because our filter is a bit different from what you are using at the web site.

    Best regards,
    Basilis

    #787479

    Yes, 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?

    #788107

    Hi,

    The Enfold Loop filter
    https://github.com/DevinVinson/enfold-child-docs/blob/master/includes/loop-index.php

    Please take a look here and let us know if it guides you at all.

    Best regards,
    Basilis

    #788661

    Is 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.

    #789167

    Hi,

    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

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.