• Weird question. For various reasons I have a form script on a particular page that’s supposed to email the content of a couple different posts. I can’t seem to write it correctly though. I can get the post content to print on the page with:

    <?php $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=1&category_name=cat1'.'&paged='.$paged);
    ?>
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php $wp_query = null; $wp_query = $temp;?>

    But when I put that in the form code I get a horrible error. So I was wondering if there was some way I could save the title and the content in a PHP variable, and echo that variable into the email? Something like this (which doesn’t work):

    <?php $cat1 =
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=1&category_name=cat1'.'&paged='.$paged);
    ?>
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php $wp_query = null; $wp_query = $temp;?>

    And then in the actual email:

    <?php echo $cat1 ?>

    I’m able to echo more simple things in the form, but I don’t know how to pass the post content through. If anyone has suggestions for me I’d really appreciate it!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘PHP variable equals post?’ is closed to new replies.