• I built custom pages with custom loops using and resetting wp_query. I installed your plugin, now every place where these custom loops for my custom post types are even on pages not password protected I receive php errors (i’m thinking your plugin doesn’t want to play nice with custom post types maybe 🙂
    Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/flooringbytileexperts/wp-content/plugins/ft-password-protect-children-pages/ft-password-protect-children-pages.php on line 72 for line 72 and 51 (where loop through ancestors)

    I call the_content multiple times on a single page (in the sidebar, etc). I am studying the plugin to see if I can work around this. If you have any thoughts I would love it.

    Thank you so much, I have used your plugin in the past with no problems (don’t know why this functionality isn’t default in wordpress)

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’ve run in to this same error – specifically on lines 51 and 72 – when trying to use shortcodes. Lines in question are:

    foreach ( $ancestors as $ancestor ) {
    			if ( post_password_required( $ancestor ) ) {
    				$output = wpautop( __('There is no excerpt because this is a protected post.') );
    				return $output;
    
    }
    
    foreach ( $ancestors as $ancestor ) {
    
    			$ancestor_post = get_post( $ancestor );
    
    			if ( post_password_required( $ancestor ) || ( isset( $ancestor_post->post_password ) && !empty( $ancestor_post->post_password ) ) ) {
    
    				$protected_title_format = apply_filters( 'protected_title_format', __('Protected: %s') );
    				$title = sprintf( $protected_title_format, $org_title );
    				return $title;
    			}

    Any ideas why the shortcode call would generate this error?

    Warning: Invalid argument supplied for foreach() in /public_html/wp-content/plugins/ft-password-protect-children-pages/ft-password-protect-children-pages.php on line 72

    I had the same problem on line 72. I’m not sure if we had the same cause of error, but I got rid of the error after editing line 69

    from

    $ancestors = $post->ancestors;

    into:

    $ancestors = Array( $post->ancestors );

    I think I had the error because $post->ancestors wasn’t an Array.

    What you should actually do is go to the file ‘ft-password-protect-children-pages/ft-password-protect-children-pages.php’ and change all three instances of
    $ancestors = $post->ancestors;
    to
    $ancestors = get_post_ancestors($post);

    This then appears to be totally compatible with WP 3.2.1 and doesn’t throw up any nasty errors.

    i see folks were using this plugin with 3.2.1, anyone get it to work with 3.3.1?

    i can log in on a parent page successfully then go to a child page and it’s not accessible, then go back to the parent and it’s password protected again.

    Thx

    @mrarrow The solution above fixed the issue. Thanks for the help!

    @fullthrottledevelopment & @blepoxp,

    Excellent plugin, can you please use this fix for your next release? Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘php errors, custom post types, multiple calls to the_content’ is closed to new replies.