WordPress.org

Ready to get started?Download WordPress

Forums

JM Twitter Cards
[resolved] Conflict with Plugin "Simply Exclude" (18 posts)

  1. Tyrannous
    Member
    Posted 1 year ago #

    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/

  2. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. Paul Menard
    Member
    Posted 1 year ago #

    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.

  4. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    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. :)

  5. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    2.1 should fix the problem :)

  7. Tyrannous
    Member
    Posted 1 year ago #

    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!

  8. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

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

  9. Tyrannous
    Member
    Posted 1 year ago #

    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.

  10. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  11. Paul Menard
    Member
    Posted 1 year ago #

    I can try and test later today.

  12. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks.

  13. Tyrannous
    Member
    Posted 1 year ago #

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

  14. Paul Menard
    Member
    Posted 1 year ago #

    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";
    	}
    }
  15. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks a lot for the tips. Code seems fine. Will run some test and I'll update. :)

  16. Paul Menard
    Member
    Posted 1 year ago #

    Not 100% sure this will solve the issue reported.

  17. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    That's why I said I have to run some test :) by the way I prefer using the_title_attribute instead of get_the_title in case title contain quotes.

  18. jmlapam
    Member
    Plugin Author

    Posted 1 year ago #

    Temporary update 2.2 will fix the problem. @pmenard : the code did not fix the problem so I did not implement it in 2.2 :/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic