Support » Plugin: Sociable » Sociable kills $post var

  • I am running a loop inside “the loop” that is looping through all of the child pages of the page that I am currently on. While inside this second loop, I set the current page data to $post, and run setup_postdata($post) on my var, as I should be, so that WordPress knows what data to work with.

    After running either the_content( ) or the_excerpt( ), my $post variable is now pointing at the original page’s data instead of whatever child page I happened to be looped to at the time.

    It seems that the Sociable plugin, in the sociable_html( ) function, is overwriting $post with the original post data from $wp_query. It probably shouldn’t do this, and should check to see if $post exists before trying to pull the original post data from $wp_query.

    Around line 735 of sociable.php is the following line:

    $post 		= $wp_query->post;

    that should be replaced with something like:

    if ( empty($post) ) {
    		$post 	= $wp_query->post;

    so that it will use whatever $post value the developer (or WordPress) may have setup, and not just assume that the data in $wp_query is the data we wish to be working with.

  • The topic ‘Sociable kills $post var’ is closed to new replies.