Results 1 to 3 of 3

Thread: Print of post from custom field

  1. #1
    curtismchale is offline Hello World
    Join Date
    Dec 2009
    Location
    BC, Canada
    Posts
    38

    Default Print of post from custom field

    I'm working on a site with user user supplied content and the blog owner will make a post then grab a recipe from the user with a custom field and post_id. I can get the custom field output on the page just fine.

    My problem comes when I try to print only the recipe (custom field off of post_id). I'm using Lester Chan's wp-print plugin. It should function like:
    http://nourishnetwork.com/2010/02/10...gel-food-cake/

    The site above does use the same print plugin. My issue specifically is that I am unable to get it to print the recipe only. It keeps printing the parent post and missing the recipe entirely. My code from single.php is below.

    Code:
    <?php get_header(); ?>
        
            <div id="content-wrapper">
                
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
                        <div class="post-content">
                            
                                                        
                            <?php $recipe = get_post_meta($post->ID, 'embed-recipe', true); ?>
                            <?php if ( $recipe ){
                                    $post_id = $recipe;
                                    $queried_post = get_post($post_id);
                            ?>
                                <div class="entry-content-recipe">
                                        <h2 class="post-title"><?php echo $queried_post->post_title; ?></h2>
                                        <div class="wp-print-text"><a href="<?php echo get_permalink($recipe); ?>print/" title="print this recipe" rel="bookmark"><?php if(function_exists('wp_print')) { print_link(); } ?></a></div>
                                    <div class="recipe-wrapper">
                                        <p><?php echo apply_filters('the_content', $queried_post->post_content); ?></p>
                                    </div><!-- / .recipe-wrapper -->
                                </div><!-- / .entry-content-recipe -->
                                <?php } else {} ?>
                        
                        </div><!-- /.post-content -->
                        
            
                <?php comments_template(); ?>
                    
                <!-- includes next previous links or post level nav -->
                <?php include_once('assets/includes/post-navigation.php'); ?>
        
                <?php endwhile; else: ?>
        
                    <p>Sorry, no posts matched your criteria.</p>
            
                <?php endif; ?>
    <div class="clear"></div>        
            </div><!-- /#content-wrapper -->
    <div class="clear"></div>            
        </div><?php // end #body-sidebar-wrap ?>
    	
    		<!-- includes wide sidebar for all pages -->
    		<?php include_once('assets/includes/wide-sidebar.php'); ?>
    
    <?php get_footer(); ?>
    Last edited by curtismchale; 02-11-2010 at 01:37 AM. Reason: didn't paste the latest copy of single.php

  2. #2
    Jeffro's Avatar
    Jeffro is offline WPTavern Forum Admin
    Join Date
    Jan 2009
    Location
    Ohio
    Posts
    2,358

    Default

    I know Lester has decreased his support activities but have you tried posting the same information on the WP-Print plugin support forum?

    http://forums.lesterchan.net/index.php?board=18.0

  3. #3
    curtismchale is offline Hello World
    Join Date
    Dec 2009
    Location
    BC, Canada
    Posts
    38

    Default

    The issue was that I called the function in his normally described method instead of directly. Not sure why it makes a difference but here is the revised working code from my single.php file.

    Code:
    <?php get_header(); ?>
    
        
    
            <div id="content-wrapper">
    
                
    
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
                    <div class="post-thumbnail">
                            <?php the_post_thumbnail(array(95,95)); ?>
                    </div><!-- /.post-thumbnail -->
                                        
                    <div class="post-heading">
                            <h2 class="post-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                            <p class="post-meta"><?php the_time('M j Y') ?> | by <?php the_author_posts_link() ?> | <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
                    </div><!-- /.post-heading -->
    
                    <div class="post-content">
                            
                        <?php the_content(); ?>
                                                        
    <div class="clear"></div>
    
                        <?php $recipe = get_post_meta($post->ID, 'embed-recipe', true); ?>
    
                        <?php if ( $recipe ){
                            $post_id = $recipe;
                            $queried_post = get_post($post_id);
                        ?>
    
                        <div class="entry-content-recipe">
    
                            <h2 class="post-title"><?php echo $queried_post->post_title; ?></h2>
    
                            <!--PRINT RECIPE-->
    
                            <div class="wp-print-text"><a href="<?php echo get_permalink($recipe); ?>print/" title="print this recipe" rel="bookmark"><img src="/wp-content/plugins/wp-print/images/printer_famfamfam.gif" /> Print this recipe</a></div>
    
                            <!--END PRINT RECIPE-->
    
                            <div class="recipe-wrapper">
                                <p><?php echo apply_filters('the_content', $queried_post->post_content); ?></p>
                            </div><!-- / .recipe-wrapper -->
    
                        </div><!-- / .entry-content-recipe -->
    
                        <?php } else {} ?>                  
    
                    </div><!-- /.post-content -->
    
                <?php comments_template(); ?>
    
                <!-- includes next previous links or post level nav -->
                <?php include_once('assets/includes/post-navigation.php'); ?>
    
                <?php endwhile; else: ?>
    
                <p>Sorry, no posts matched your criteria.</p>
    
                <?php endif; ?>
    
    <div class="clear"></div>        
    
            </div><!-- /#content-wrapper -->
    
    <div class="clear"></div>            
    
        </div><?php // end #body-sidebar-wrap ?>
    
                <!-- includes wide sidebar for all pages -->
                <?php include_once('assets/includes/wide-sidebar.php'); ?>
    
    <?php get_footer(); ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •