Guest User

Untitled

a guest
Jan 23rd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2. if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  3. <div class="blog-post">
  4. <ul id="projects">
  5. <li>
  6. <div class="blog-post-title">
  7. <a class="project" rel="<?php the_permalink();?>" href="<?php the_permalink();?>">
  8. <?php the_title(); ?></a>
  9. </div>
  10. <span class="blog-post-meta"><?php echo get_the_date(); ?> by <a href="#"><?php the_author(); ?></a></span>
  11. </li>
  12. </ul>
  13. </div>
  14. <?php endwhile; endif; ?>
  15.  
  16. </div>
  17. <div id="project-single">
  18. <div id="inner-single"></div>
  19. </div>
  20.  
  21. jQuery(document).ready(function ($) {
  22. $.ajaxSetup({cache: false});
  23. $("a.project").click(function () {
  24. var post_link = $(this).attr("href");
  25. alert(post_id);
  26. $("#inner-single").html('<div class="loading">loading...</div>');
  27. $("#inner-single").load(post_link);
  28. return false;
  29. });
  30. });
  31.  
  32. <?php $post = get_post($_POST['id']); ?>
  33. <div id="single-post post-<?php the_ID(); ?>">
  34. <?php while (have_posts()) : the_post(); ?>
  35. <?php the_content();?>
  36. </div>
  37. <?php endwhile;?>
  38. <?php get_footer(); ?>
  39.  
  40. function ajax_enable () {
  41. wp_enqueue_script( 'admin_url', includes_url() . 'js/myajax.js', array( 'jquery' ) );
  42. $admin_url = array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ) );
  43. wp_localize_script( 'admin_url', 'AdminURL', $admin_url );
  44. }
  45. add_action( 'wp_enqueue_scripts', 'ajax_enable' );
Add Comment
Please, Sign In to add comment