Support » Plugin: Posts 2 Posts » [Plugin: Posts 2 Posts] Connection not showing in front-end in preview

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author scribu

    (@scribu)

    I don’t understand what you mean by “proof the connection”.

    In general, I’m having a hard time understanding what the issue is.

    Hi

    I installed front end editor in http://www.grandtrustbrokers.com/
    But it is totally inactive in my site.

    Please help to make it work in my site.

    Plugin Author scribu

    (@scribu)

    @shahed2535: This thread is for the Posts 2 Posts plugin. Please open a new thread in the appropriate place (after reading the FAQ).

    Hi sorry, I’ve re-read my problem and it makes no sense :-p I’ll try again.

    The way I use posts 2 posts means it’s important for me to view how a connection looks prior to it being published. Before (the update) I could hit preview and it would show the meta data from connected posts as I wanted it, however, now it no longer does that. It will show the post as connected prior to publishing, but any connected information that is grabbed from one post to a connected post only shows after publishing – thus I’m unable to preview (proof) it correctly.

    We’re having the same problem as djhsecondnature.

    We have a custom post type for ‘featured product’, which we’re linking to individual blog posts. Each blog post has a box at the bottom for featured product. When we preview a blog post before it’s published, the featured product isn’t shown. After the post is published, preview shows the featured post box, but not before, and our writers are unhappy because they’d like to be able to preview the featured product box before publishing the post.

    Can anyone help?

    Here’s the code:

    // add connection type
    function my_connection_types() {
    	p2p_register_connection_type( array(
    		'name' => 'posts_to_featured_products',
    		'from' => 'post',
    		'to' => 'featured_products'
    	) );
    }
    add_action( 'p2p_init', 'my_connection_types' );
    
    // add product box after content
    add_action('template_redirect', 'product_conditional_actions');
    function product_conditional_actions() {
    	if( is_single() && !is_singular( 'featured_products' ) ) {
    	add_action('genesis_after_post_content', 'add_featured_product_box');
    	}
    }
    
    function add_featured_product_box() {
    
    	// Find connected pages
    	$connected = new WP_Query( array(
    	  'connected_type' => 'posts_to_featured_products',
    	  'connected_items' => get_queried_object(),
    	  'nopaging' => true,
    	) );
    
    	// Display connected pages
    	if ( $connected->have_posts() ) :
    	?>
    	<div class="featuredproductteaser">
    		<?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    
    				<?php $producturl=get_post_meta(get_the_ID(), 'product_url', true);
    					if ( $producturl ) { ?>
    
    						<?php if ( has_post_thumbnail() ) { ?>
    							<a href="<?php echo $producturl; ?>" target="_blank">
    								<?php the_post_thumbnail('featured-product-thumb'); ?>
    							</a>
    							<?php } ?>
    						<div class="copy">
    							<h2>Featured resource</h2>
    							<h3><a href="<?php echo $producturl; ?>" target="_blank"><?php the_title(); ?></a></h3>
    							<?php the_excerpt(); ?>
    							<p class="flink"><a href="<?php echo $producturl; ?>" target="_blank">Get it now</a></p>
    						</div>
    
    					<?php } else { ?>
    
    						<?php if ( has_post_thumbnail() ) { ?>
    							<a href="<?php echo $producturl; ?>" target="_blank">
    								<?php the_post_thumbnail('featured-product-thumb'); ?>
    							</a>
    							<?php } ?>
    						<div class="copy">
    							<h2>Featured resource</h2>
    							<h3><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></h3>
    							<?php the_excerpt(); ?>
    							<p class="flink"><a href="<?php the_permalink(); ?>" target="_blank">Get it now</a></p>
    						</div>
    
    				<?php } ?>
    
    		<?php endwhile; ?>
    	</div>
    	<?php
    	// Prevent weirdness
    	wp_reset_postdata();
    
    	endif;
    
    	}
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Posts 2 Posts] Connection not showing in front-end in preview’ is closed to new replies.