Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('WP_USE_THEMES', false);
- ?>
- <?php
- require('./editorials/wp-load.php');
- $content1 = array();
- ?>
- #start editorials loop
- <ul>
- <?php $the_query = new WP_Query( 'posts_per_page=10' ); ?>
- <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
- <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
- <li><?php the_excerpt(__('(more…)')); ?></li>
- <?php
- $content1[]=array(get_the_date('Ymd'). '%%' . get_the_id(). '%%' . get_the_title(). '%%' . get_the_permalink(). '%%' . get_the_author(). '%%' . get_the_post_thumbnail(). '%%'. wp_first_paragraph_excerpt($content));
- //print_r ($content1);
- ?>
- <?php
- endwhile;
- wp_reset_postdata();
- ?>
- </ul>
- #end editorials loop
- <?php
- require('./news/wp-load.php');
- wp_reset_query();
- $content2 = array();
- ?>
- #start news loop
- <ul>
- <?php $the_query = new WP_Query( 'posts_per_page=10' ); ?>
- <?php wp_reset_postdata();
- wp_reset_query();
- ?>
- <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
- <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
- <li><?php the_excerpt(__('(more…)')); ?></li>
- <?php
- $content2[]=array(get_the_date('Ymd'). '%%' . get_the_id(). '%%' . get_the_title(). '%%' . get_the_permalink(). '%%' . get_the_author(). '%%' . get_the_post_thumbnail(). '%%'. wp_first_paragraph_excerpt($content));
- //print_r ($content2);
- ?>
- <?php
- endwhile;
- ?>
- #all done
- <?php
- function wp_first_paragraph_excerpt($content) {
- // Get the post content
- $content = get_the_content();
- $content = apply_filters( 'the_content', strip_shortcodes( $content ) );
- // Remove all tags, except paragraphs
- $excerpt = strip_tags( $content, '<p></p>' );
- // Remove empty paragraph tags
- $excerpt = force_balance_tags( $excerpt );
- $excerpt = preg_replace( '#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $excerpt );
- $excerpt = preg_replace( '~\s?<p>(\s| )+</p>\s?~', '', $excerpt );
- // Get the first paragraph
- $excerpt = substr( $excerpt, 0, strpos( $excerpt, '</p>' ) + 4 );
- // Remove remaining paragraph tags
- $excerpt = strip_tags( $excerpt );
- return $excerpt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement