Advertisement
orksnork

Untitled

May 6th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1. <?php while (have_posts()) : the_post(); ?>
  2.     <article <?php post_class( 'row' ); ?>>
  3.  
  4.         <?php
  5.             $content = get_the_content();
  6.             $content = apply_filters( 'the_content', $content );
  7.             $content = str_replace( ']]>', ']]&gt;', $content );
  8.  
  9.             preg_match_all( "/<h1>(.*?)<\/h1>/si", $content, $matches );
  10.             list( $with_tags, $without_tags) = $matches;
  11.  
  12.             if ( $with_tags ) {
  13.             ?>
  14.             <div class="col-md-3 hidden-xs">
  15.                 <div class="bs-sidebar hidden-print affix">
  16.                     <ul class="nav bs-sidenav">
  17.                         <?php
  18.                         foreach ($without_tags as $link_text) {
  19.                             $slug = sanitize_title_with_dashes( $link_text );
  20.  
  21.                             printf('<li><a href="#%s"><i class="fa fa-chevron-right pull-right"></i> %s</a></li>', $slug, strip_tags( $link_text ) );
  22.                         }
  23.                         ?>
  24.                     </ul>
  25.                 </div>
  26.             </div>
  27.             <?php } ?>
  28.  
  29.             <div class="col-md-<?php echo $with_tags ? '9' : '12'; ?>">
  30.                 <div class="entry-content">
  31.                     <header>
  32.                         <h1 class="entry-title"><?php the_title(); ?></h1>
  33.                     </header>
  34.                     <?php
  35.                     foreach ($without_tags as $link_text) {
  36.                         $slug = sanitize_title_with_dashes( $link_text );
  37.                         $replace = sprintf('<div class="spy-item" id="%s"></div>', $slug );
  38.                         $replace = $replace . '<div class="page-header"><h3 class="section-title">' . $link_text . '</h3></div>';
  39.  
  40.                         $content = str_replace("<h1>$link_text</h1>", $replace, $content);
  41.                     }
  42.  
  43.                     echo $content;
  44.                     ?>
  45.                 </div>
  46.  
  47.                 <?php get_template_part( 'templates/content', 'feedback' ); ?>
  48.  
  49.             </div><!-- .col-md-# -->
  50.     </article>
  51. <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement