/ Published in: PHP

If you need on ajax request to get only the post content
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { if ( have_posts() ) : // Start the Loop. while ( have_posts() ) : the_post(); ?> <div data-title="<?php the_title(); ?>"></div> <?php get_template_part( 'content', get_post_format() ); endwhile; else : // If no content, include the "No posts found" template. get_template_part( 'content', 'none' ); endif; } ?>
URL: www.bassta.bg
Comments
