WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Conflict with Plugin "Simply Exclude"

[Resolved] Conflict with Plugin "Simply Exclude"

  • Hi,
    I noticed some weird behaviour:
    I use the Plugin “Simply Exclude” to hide a certain category from homepage.
    When checking the homepage’s twitter meta data created by your plugin I noticed that the description contains an excerpt from the last post of the HIDDEN category!
    When I delete all posts of this category twitter:url, twitter:title, twitter:description and twitter:image are empty. I don’t know what should be there instead but I’m sure it shouldn’t be empty…

    It would be great if you could check this behaviour or even fix it!
    Thanks!

    http://wordpress.org/extend/plugins/jm-twitter-cards/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author tweetpressfr

    @jmlapam

    Hi,
    I did not know this plugin so I’ll do some test as soon as I can and see how it’s coded and if I can fix this bug.

    Thanks for reporting.

    jmlapam, I’m the author of the Simply Exclude plugin. I caught this thread in my feed. Let me know if you find any conflict on my end. The SE plugin basically will allow filtering of the main page wp_query. The principle functionality is simple as in this Codex page. The SE plugin just builds atop that basic functionality for Post Types and Taxonomies.

    Plugin Author tweetpressfr

    @jmlapam

    hi pmenard, OK. I’ll check it. To my side conflict my be due to the way I get the excerpt but I do not have a lot of possibilities simply because we are oustide the loop. Hopefully this bug will be fixed. 🙂

    Plugin Author tweetpressfr

    @jmlapam

    Yeh I kinda understand the problem. Actually @Tyranous this came from my plugin which does not work with home or post page. Thanks for reporting.

    Plugin Author tweetpressfr

    @jmlapam

    2.1 should fix the problem 🙂

    Thanks for the update!
    On “home” twitter:description works now (it’s awesome to be able to use an individual description text!) but twitter:url and twitter:title still show the values from the last post of the hidden category.
    It’ll be great if you could fix this!
    Thank you!

    Plugin Author tweetpressfr

    @jmlapam

    It can’t be. There are no longer set with the same code. Try to refresh.

    Well it’s strange. Here’s what I get with version 2.1:

    Testsite with one category excluded:

    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:creator" content="@username
    <meta name="twitter:site" content="@username"/>
    <meta name="twitter:url" content="http://example.com/url-of-post-from-hidden-category"/>
    <meta name="twitter:title" content="Title of Post from hidden Category"/>
    <meta name="twitter:description" content="Welcome site title - see blog posts"/>
    <meta name="twitter:image" content="http://www.gravatar.com/avatar/avatar.jpg"/>

    Note: Permalinks set to “post name”

    Testsite with no posts in hidden category:

    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:creator" content="@username"/>
    <meta name="twitter:site" content="@username"/>
    <meta name="twitter:url" content="http://example.com/?page_id="/>
    <meta name="twitter:title" content=""/>
    <meta name="twitter:description" content="Welcome to site title - see blog posts"/>
    <meta name="twitter:image" content="http://www.gravatar.com/avatar/avatar.jpg"/>

    Another testsite with one category excluded:

    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:creator" content="@TweetPressFr"/>
    <meta name="twitter:site" content="@TweetPressFr"/>
    <meta name="twitter:url" content="http://example2.com/url-of-first-visible-post/"/>
    <meta name="twitter:title" content="Title of first visible post"/>
    <meta name="twitter:description" content="Welcome to Testseite - see blog posts"/>
    <meta name="twitter:image" content="http://www.gravatar.com/avatar/avatar.jpg"/>

    Thats what I actually expect to see:

    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:creator" content="@username"/>
    <meta name="twitter:site" content="@username"/>
    <meta name="twitter:url" content="http://example.com/"/>
    <meta name="twitter:title" content="Title of site"/>
    <meta name="twitter:description" content="Welcome to Testseite - see blog posts"/>
    <meta name="twitter:image" content="http://www.gravatar.com/avatar/avatar.jpg"/>

    Am I right?

    I have no idea why it still gets values from hidden category on my first testing site… I even deleted and reinstalled the plugin with no effort.

    Plugin Author tweetpressfr

    @jmlapam

    So eventually this does not come from my plugin. The fact is I can’t manage to simulate your bug. Plus new code uses appropriate function so I guess the other plugin “Simply Exclude” is modifying the main query of your home page.

    I’ll try to figure out how to fix it but I won’t have a lot of time this week. I’ll do my best. First I have to look into the code of Simply Exclude.

    Anyway, thanks for reporting.

    I can try and test later today.

    Plugin Author tweetpressfr

    @jmlapam

    Thanks.

    Update:
    Because I deactivated and activated both plugins many times I didn’t noticed that Simply Exclude has been reset from “Exclude” categories to “Include only” and “Query filtering” from “All Loops” to “Main Loop Only”.
    Because of “Main Loop Only” the plugin wasn’t working with my theme anymore. We have many posts on homepage so I didn’t realised that posts were visible from all categories although they rather shouldn’t.
    That’s why I didn’t noticed earlier that the plugin has been reset.

    Situation with “Main Loop Only” while theme requires “All Loops”:

    If Simply Exclude is set to “Include only” but the selected category contains no posts, Twitter Cards would output the following:

    <meta name="twitter:url" content="http://example.com/?page_id="/>
    <meta name="twitter:title" content=""/>

    (see second code paragraph)

    If Simply Exclude is set to “Include only” and the selected category contains posts, Twitter Cards would output the following:

    <meta name="twitter:url" content="http://example.com/url-of-post-from-hidden-category"/>
    <meta name="twitter:title" content="Title of Post from hidden Category"/>

    (see first code paragraph)
    In this case “hidden category” is the included category.
    That was the situation which was driving me crazy.

    If Simply Exclude is set to “Exclude” a category (with and without posts) Twitter Cards would output the following:

    <meta name="twitter:url" content="http://example2.com/url-of-first-visible-post/"/>
    <meta name="twitter:title" content="Title of first visible post"/>

    (see third paragraph)
    That seems to be correct.

    I’m not a developer but I think it has to do with Twitter Cards “listenting” to main loop but the theme doesn’t?

    Whew. It took me some hours to figure this out… 😉
    (Hopefully you’ll understand what I’m talking about; explaining this in english isn’t easy.)

    In your function add_twitter_card_info() you have the following lines.

    if (is_home() || is_front_page()) {
    	echo "\n".'<!-- JM Twitter Cards by Julien Maury (version 2.1) -->'."\n";  	                   					
    
    	echo '<meta name="twitter:card" content="'. $opts['twitterCardType'] .'"/>'."\n";
    	echo '<meta name="twitter:creator" content="@'. $opts['twitterCreator'] .'"/>'."\n";
    	echo '<meta name="twitter:site" content="@'. $opts['twitterSite'] .'"/>'."\n";			
    
    	//post page var
    	$posts_page_id = get_option( 'page_for_posts');
    	// Paul The value of $posts_page_id is ONLY valid IF showing a static Page on front. 
    
    	$posts_page = get_page( $posts_page_id);
    	$posts_page_title = $posts_page->post_title;
    	$posts_page_url = get_page_link($posts_page_id  );									
    
    	echo '<meta name="twitter:url" content="' . $posts_page_url . '"/>'."\n";
    	echo '<meta name="twitter:title" content="' . $posts_page_title . '"/>'."\n";
    	echo '<meta name="twitter:description" content="' . $opts['twitterPostPageDesc'] . '"/>'."\n"; 
    
    	echo '<meta name="twitter:image" content="' . $opts['twitterImage'] . '"/>'."\n";
    
    	echo '<!-- /JM Twitter Cards -->'."\n\n";
    }

    Change code to be more aware of showing static Page vs. latest posts. Also be aware of no posts

    if (is_home() || is_front_page()) {
    
    	$posts_page_title = $posts_page_url = '';
    
    	//post page var
    	$posts_page_id = get_option( 'page_for_posts');
    	if ($posts_page_id != 0) {
    		// Showing static Page on Front
    		$posts_page = get_page( $posts_page_id);
    		$posts_page_title = $posts_page->post_title;
    		$posts_page_url = get_page_link($posts_page_id  );
    	} else if (have_posts()) { // Make sure we have posts.
    		// Showing posts on Front
    		global $post;	// The $post contains the first item in the loop which will be displayed.
    		$posts_page_title 	= get_the_title( $post->ID );
    		$posts_page_url 	= get_page_link( $post->ID );
    	}
    
    	if ( (!empty($posts_page_title)) && (!empty($posts_page_url)) ) {
        	echo "\n".'<!-- JM Twitter Cards by Julien Maury (version 2.1) -->'."\n";
    		echo '<meta name="twitter:card" content="'. $opts['twitterCardType'] .'"/>'."\n";
    		echo '<meta name="twitter:creator" content="@'. $opts['twitterCreator'] .'"/>'."\n";
    		echo '<meta name="twitter:site" content="@'. $opts['twitterSite'] .'"/>'."\n";
    		echo '<meta name="twitter:url" content="' . $posts_page_url . '"/>'."\n";
    		echo '<meta name="twitter:title" content="' . $posts_page_title . '"/>'."\n";
    		echo '<meta name="twitter:description" content="' . $opts['twitterPostPageDesc'] . '"/>'."\n";
    		echo '<meta name="twitter:image" content="' . $opts['twitterImage'] . '"/>'."\n";
            echo '<!-- /JM Twitter Cards -->'."\n\n";
    	}
    }
    Plugin Author tweetpressfr

    @jmlapam

    Thanks a lot for the tips. Code seems fine. Will run some test and I’ll update. 🙂

    Not 100% sure this will solve the issue reported.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Resolved] Conflict with Plugin "Simply Exclude"’ is closed to new replies.