We wrote about:

WP-Email custom post type quick fix

This is not so much a task that I thought “wouldn’t that be a nice thing to spend the last half hour on“, but its a great plugin bar the fact it currently gives a 404 error for Custom Post Types (WordPress 3) so thought worth having a look (Version 2.52). Searching around showed lots of people with similar problems so am posting in case this ‘quick and dirty’ 404 fix helps get things started.

Does anyone want to collaborate with us? I’m sure its fairly simple and we made some progress – here is where we are at:

Below is a fix to override the permalink route of calling the function with a query string, removing the 404 error and it sends the email out and logs it ok:

On our version (with double spacing) it’s around line 497 in /plugins/wp-email/wp-email.php (or search for “$email_link = $email_link.’email/’;”).

Replace:

} else {

With:

} elseif( get_post_type() != "post" ){
$email_link = $email_link.'?email=1';
} else {

The email came through, but did not contain the link details:

Hi Mr X,
Your friend, Mr Y, has recommended this article entitled ‘‘ to you.

Here is his/her remark:
I like it


Posted By On In

Article taken from OC Student Lettings – http://www.maindomain.co.uk
URL to article:

Have you got any further?

wp1

27/10/2010

Written by James Montgomery, Designer & Developer.

Back

  • http://twitter.com/jkohlbach Josh Kohlbach

    Hey, have you managed to get any further than this? I’m stuck at the same point.

    • http://twitter.com/jkohlbach Josh Kohlbach

      Just following up here..

      You’ll need to change the post query used to retrieve the post during emailing (approx line 850~ in wp-email.php)

      Replace the whole block with this:

      // Get Post Information
      if($p > 0) {
      $post_type = get_post_type($p);
      $query_post = ‘p=’. $p . ‘&post_type=’ . $post_type;
      $id = $p;
      } else {
      $query_post = ‘page_id=’.$page_id;
      $id = $page_id;
      }

  • Anonymous

    Thanks Josh, I hadn’t had much opportunity to look so will try that out today… looks a nice fix.

  • Andreieleonte35

    There are a lot of } else { . I changed all of them and still not working …

    • Anonymous

      Hi there,

      I would recommend restoring that file, then searching for: $email_link = $email_link.’email/’;

      Once you have that, just look around that point for the } else { to tweak. Our file was double spaced, so in theory its line ~248 (or 497 if double spaced).

      Hope that helps.

      James

      • Andreieleonte35

        Yes you are right. It’s working on the 248 line. How about emailpopup ? Will this code make it work too (277 line) ?

        • Andreieleonte35

          Hi,

          Thanks for info. I made it work replacing “?email=1″ with “?emailpopup=1″ and I also I used this : <a class="email" href="?emailpopup=1″ title=”Email to a friend” onclick=”email_popup(this.href); return false;” rel=”nofollow”>Email to a friend

          • Anonymous

            Thanks for the update and glad the first comment was of use.

            Second code block from post above:
            ?emailpopup=1" title="Email to a friend" onclick="email_popup(this.href); return false;" rel="nofollow"

    • Anonymous

      Hi there,

      I would recommend restoring that file, then searching for: $email_link = $email_link.’email/’;

      Once you have that, just look around that point for the } else { to tweak. Our file was double spaced, so in theory its line ~248 (or 497 if double spaced).

      Hope that helps.

      James

  • Anonymous

    The easiest way to fix this is to simply visit your Settings > Permalinks page.
    No changes of code.

  • http://www.hire-web-developers.com/ website coder

    Can you please share that links detail.. I think that link details are very useful for us.. Thanks a lot..

  • Anonymous

    thanks so much for this guys ..

    there’s a fix for the content being sent at this link: http://forums.lesterchan.net/index.php/topic,4824.msg31161.html#msg31161

  • http://twitter.com/gamerz Lester Chan

    try the dev version, I have added a fix by one of my forum members. http://downloads.wordpress.org/plugin/wp-email.zip

  • Pingback: wp-email [FIX] | AppThemes Forum

  • Gary

    Just want to thank you for the post, it helped big time!