WordPress.org

Ready to get started?Download WordPress

Forums

WP-EMail
Plugin not working with custom post type (29 posts)

  1. maorb
    Member
    Posted 3 years ago #

    Hi,

    I created a custom post type and put the mail button in a single post of the type.
    In the regular posts it is working well, but in the custom post type I gt error 404 of a pgae not found.
    I tried to resave the permalinks with no help.
    I use the Custom Post Permalinks plugin to give my custom posts type a different permalink structure, so it might be that the wp-email cannot handle this?

    I will be happy if someone has a solution for that.

    Thanks

    http://wordpress.org/extend/plugins/wp-email/

  2. vernal
    Member
    Posted 3 years ago #

    Yes, I'm having the same problem as well. No solution found thus far.

  3. maorb
    Member
    Posted 3 years ago #

    Will the plugin developer working on a way to fix this for custom post types?

  4. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    I checked the code, it doesn't seem to be specified to any post types. Does it work out of the box with custom post type without any plugins changging the default permalink?

  5. vernal
    Member
    Posted 3 years ago #

    Hey Lester,

    I just gave that a shot and it did not work. It's good on pages and posts but not on anything custom. I'm happy to help more if you need me.

  6. maorb
    Member
    Posted 3 years ago #

    I have just tested it now also, tried to deactivate the Custom Post Permalinks plugin, resaved the permalinks and it didn't work for me, still get 404 when clicking the email button.

    But, if I don't use permalinks at all, and using WordPress default (i.e. with the query strings in the url) so the email button starts working for custom post types as well.

    So, it appears the issue is with custom post type and non default permalinks, and not an issue with that Custom Post Permalink plugin.

    Do you have an idea how this can be fixed?

    Many thanks

  7. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Hmm, I will look into it. Maybe this weekend =)

  8. maorb
    Member
    Posted 3 years ago #

    Thanks Lester, waiting for your updates.
    If you need, I'll be happy to help with testing or reviewing code.

  9. maorb
    Member
    Posted 3 years ago #

    @Lester, Is there any chance that you will have the time to release a fix for this issue soon?

    Many thanks

  10. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Sorry man, was busy with other plugins. Will try my best.

  11. vernal
    Member
    Posted 3 years ago #

    Great. Thanks, Lester. Let me know if you need help testing.

  12. maorb
    Member
    Posted 3 years ago #

    Is there a progress with this bug, or this won't work anymore?

    This plugin is very useful, but cannot be used with Custom Post Types.

    Many thanks

  13. worldwisewebs
    Member
    Posted 3 years ago #

    +1 for a fix - great plugin, needs custom post type support :)

  14. worldwisewebs
    Member
    Posted 3 years ago #

    http://www.realisingdesigns.com/2010/10/27/wp-email-custom-post-type-quick-fix/

    http://forums.lesterchan.net/index.php/topic,4824.msg31161.html#msg31161

    ^^^between these two you can make this work :) added links for anyone else running the wild goose chase...

  15. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Can anyone try the dev version http://downloads.wordpress.org/plugin/wp-email.zip ?

    Thanks to worldwisewebs for bringing the forum post to my attention and thanks to jkohlbach for the fix.

    Once you guys have verified it has work, I will release it =)

    Been really busy with my work. Sorry about that.

  16. maorb
    Member
    Posted 3 years ago #

    I downloaded the dev version and tried it.
    I still get 404 on Custom Post Types. Tried to resave the permalinks structure but it didn't help neither.

  17. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Yeap, I just realized that, the fix is for user not using nice permalink. I need to find a way to generate permalinks for custom post type.

  18. worldwisewebs
    Member
    Posted 3 years ago #

    I am using custom permalinks and the fixes at the links above have worked for me.. I haven't had a chance to download your new zip and test it on my site yet though.

    one bug I have noticed though is that for some reason that I haven't quite figured out yet, once in a while, seemingly randomly, all of my permalinks will suddenly be hosed and everything will redirect to the home page (not good!!) .. To fix I have to disable wp-email, resave my permalinks, and reenable wp-email..

    ??? Haven't had any time to chase this out and it only seemed to happen in my first setups of the plugin so I'm not sure what to make of it.

    Thanks a lot for working on this Lester, I know continuing to support free software when your paid work is calling can be tricky!!

  19. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks worldwisewebs, I try my best, was in the midst of debugging it when i was called for a urgent project development =(

  20. danbejarano
    Member
    Posted 3 years ago #

    Thank you Lester for helping the community.
    This I found in a review about custom post types.

    Help! I’m getting a 404!

    If you’re getting a 404 message when trying to view a post, don’t worry. This is supposed to happen when setting up new post types. The easiest way to fix this is to simply visit your Settings > Permalinks page. You don’t have to save your permalinks but just visit the page. This will flush your rewrite rules.

    If you’re a plugin author, you can save yourself some support questions by flushing the rewrite rules on activation of your plugin.

    source: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress

  21. danbejarano
    Member
    Posted 3 years ago #

    How about: add_action('admin_init', 'flush_rewrite_rules');

  22. maorb
    Member
    Posted 3 years ago #

    @danbejarano flushing rewrites does not help in this case.

  23. maorb
    Member
    Posted 3 years ago #

    This issue is still not solved, unfortunately.

  24. maorb
    Member
    Posted 3 years ago #

    Well, I finally had a bit of time to dig Lester Chan's code and I'm happy to say I have a working solution.
    I really do not like to follow others code and do reverse engineering, but in this case there was no choice, since I needed this feature for my client and it appeared that Lester has no time to check this.

    To remind you, the problem was when trying to use the plugin with Custom Post Type and with non-default permalinks structure.

    My solution deals only with using the stand alone page, and not with the popup option (In the matter of fact, I am using the stand alone email page and taking the div with the form in order to pop it up into a nice colorbox window, since popups are so 90's and part of the time blocked..)

    Line numbers inside the code are referring to latest WP-Email ver2.5.2.
    Go to line 234, you will find this block of code in lines 234-261

    switch($email_type) {
    		// E-Mail Standalone Page
    		case 1:
    			if(!empty($using_permalink)) {
    				if(substr($email_link, -1, 1) != '/') {
    					$email_link= $email_link.'/';
    				}
    				if(is_page()) {
    					if(empty($email_page_text)) {
    						$email_text = stripslashes($email_options['page_text']);
    					} else {
    						$email_text = $email_page_text;
    					}
    					$email_link = $email_link.'emailpage/';
    				} else {
    					$email_link = $email_link.'email/';
    				}
    			} else {
    				if(is_page()) {
    					if(empty($email_page_text)) {
    						$email_text = stripslashes($email_options['page_text']);
    					} else {
    						$email_text = $email_page_text;
    					}
    				}
    				$email_link = $email_link.'&email=1';
    			}
    			break;

    You should replace it with this:

    switch($email_type) {
    		// E-Mail Standalone Page
    		case 1:
    			if(!empty($using_permalink)) {
    				if(substr($email_link, -1, 1) != '/') {
    					$email_link= $email_link.'/';
    				}
    				if(is_page()) {
    					if(empty($email_page_text)) {
    						$email_text = stripslashes($email_options['page_text']);
    					} else {
    						$email_text = $email_page_text;
    					}
    					$email_link = $email_link.'emailpage/';
    				}
    				elseif (is_singular() && !is_singular('post'))	{
    					$email_link = $email_link.'?email=1';
    				}
    				else {
    					$email_link = $email_link.'email/';
    				}
    			} else {
    				if(is_page()) {
    					if(empty($email_page_text)) {
    						$email_text = stripslashes($email_options['page_text']);
    					} else {
    						$email_text = $email_page_text;
    					}
    				}
    				$email_link = $email_link.'&email=1';
    			}
    			break;

    What I have actually changed, is adding these lines to 249-251 -

    elseif (is_singular() && !is_singular('post'))	{
    					$email_link = $email_link.'?email=1';
    				}

    It will tell WP that if you are in a case of using non-default permalinks, and you are on a single page of a non-post type (aka, custom post type), than to populate the email page with a query variable ?email=1.

    Well, it works for me, and opening the standalone and also of course my nice colorbox.

    I hope it will help some of you.
    Lester Chan, if you add this as a version fix, I'd be happy if you could grant me a small credit of thanks inside the plugin :)

  25. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks for the time maorb! I think that is still a partial fix as url now has been appended with email=1 instead of just /email/.This is top of my list of my WP plugins as this affected WP-Print as well. I just need to find time =(

  26. maorb
    Member
    Posted 3 years ago #

    Yes, it does adds ?email=1 instead of /email/. There should be no issue using the query variable in the url. It is better to have this instead of pretty permalink that leads to 404 page...

  27. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Agreed, I have problems finding the api that leads to the permalink generation for custom post types.

    What WP-Email does it gets the permalink, extract the approiate permalink, append /email to it and add back to the rewrite rule.

  28. maorb
    Member
    Posted 3 years ago #

    Maybe you could try asking in WordPress Stackexchange, someone might know to lead you with this issue?

  29. ignitionmedia
    Member
    Posted 3 years ago #

    Hi there
    has there been any progress on this? I also need it to work for WP-Print

    thanks very much for your work on this matter.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags