Advertisement
joelgoodman

Move Jetpack Related Posts

Mar 3rd, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?php
  2.  /* In functions.php */
  3.  
  4. /**
  5.  * Remove Related Posts auto-injecting
  6.  *
  7.  */
  8. function jetpackme_remove_rp() {
  9.     if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
  10.         $jprp = Jetpack_RelatedPosts::init();
  11.         $callback = array( $jprp, 'filter_add_target_to_dom' );
  12.         remove_filter( 'the_content', $callback, 40 );
  13.     }
  14. }
  15. add_filter( 'wp', 'jetpackme_remove_rp', 20 );
  16.  
  17.  
  18.  
  19. /* Inside single.php */
  20.  
  21. get_header(); ?>
  22.  
  23.     <div id="primary" class="content-area">
  24.         <main id="main" class="site-main" role="main">
  25.  
  26.         <?php while ( have_posts() ) : the_post(); ?>
  27.  
  28.             <?php get_template_part( 'content', 'single' ); ?>
  29.             <?php get_template_part('parts/news/related', 'posts'); ?>
  30.         <?php endwhile; // end of the loop. ?>
  31.  
  32.         </main><!-- #main -->
  33.     </div><!-- #primary -->
  34. <?php get_footer();
  35.  
  36.  
  37.  
  38.  
  39. /* Inside content-single.php */ ?>
  40.  
  41. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  42.     <header class="entry-header">
  43.         <div class="constraint">
  44.             <div class="entry-title-group">
  45.                 <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
  46.             </div>
  47.             <?php
  48.                 if ( has_post_thumbnail() ) {
  49.                     echo '<figure class="post-image-container">';
  50.                         the_post_thumbnail( 'post-thumbnail');
  51.                     echo '</figure>';
  52.                 }
  53.             ?>
  54.         </div>
  55.     </header><!-- .entry-header -->
  56.     <section class="news-story">
  57.         <div class="share-bar"><?php if ( function_exists( 'sharing_display' ) ) { sharing_display( '', true ); } ?></div>
  58.         <div class="entry-content">
  59.             <div class="entry-meta">
  60.                 <?php the_date('F j, Y', '<time datetime="' . get_the_time('U') . '">', '</time>'); ?>
  61.             </div><!-- .entry-meta -->
  62.             <?php the_content(); ?>
  63.         </div><!-- .entry-content -->
  64.     </section>
  65. </article><!-- #post-## -->
  66.  
  67. <?php
  68.  
  69.  
  70.  
  71. /* Inside /parts/news/related-posts.php */ ?>
  72.  
  73. <aside class="jetpack-rp">
  74.     <h3><span>Related Posts</span></h3>
  75.     <div class="related-posts-wrapper">
  76.         <?php
  77.             if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
  78.                 echo do_shortcode( '[jetpack-related-posts]' );
  79.             }
  80.         ?>
  81.     </div>
  82. </aside>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement