Support » Plugins » Hacks » generate a newsletter of wordpress posts per month

  • Hi,

    I would like to generate a newsletter of wordpress posts (title post + excerpt or content + title of category) of last month.

    So, I generate a new file in php (with fopen, fwrite, etc…) in which I put template code. But I have a problem to generate posts.

    I’ve made required of major files :


    When I put this function : `get_archives(‘postbypost’, ’10’, ‘custom’, ‘
    <li>’, ‘</li>

    it runs but not with this code for example :

    while (have_posts()) : the_post();
      // the content of the post
      the_content('Read the full post ยป');

    Do you know why ?

    Thank for you help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • up ! ๐Ÿ™‚

    I’ve test in command line on my server with : php -f /var/mon-ndd/www/newsletters/genere-newsletter.php but I havn’t warnings / errors…

    I’ve added a if (have_posts()) and result is “Sorry, no post published”.

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h2>” href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endwhile; else: ?>
    <p>Sorry, no post published.</p>
    <?php endif; ?>

    So, there is no post for it… Do I have to include another php file ?

    I’ve found ! I’ve added query_posts

    But I cannot write wordpress data in my file. For example, there, $permalink and $title are displayed on my screen but are not writted in the file. Do you know how can I resolve this problem ?

    while (have_posts()) : the_post();
    fwrite($fp, ‘<tr>’);
    fwrite($fp, ‘<td>’);
    fwrite($fp, ‘<p>’);
    fwrite($fp, ‘<a href=”‘);
    $permalink = the_permalink();
    fwrite($fp, $permalink);
    fwrite($fp, ‘”>’);
    $title = the_title();
    fwrite($fp, $title);
    fwrite($fp, ”);
    fwrite($fp, ‘</p>’);
    fwrite($fp, ‘</td>’);
    fwrite($fp, ‘</tr>’);

    Thanks to you ๐Ÿ™‚

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘generate a newsletter of wordpress posts per month’ is closed to new replies.