Save meta message and reuse them

So, I have two files (first read " ) Edit: Clarification

first.php:

<div class="rfp_hide " >
    <?php   
    $args = array( 
        'post_type' => 'post',
        'paged'=>$paged,
        'posts_per_page' => 15,         
        'orderby' => 'date',            
        'order' => 'DESC'
        );
    $loop = new WP_Query( $args );
    $id = get_the_ID();     
    while ( $loop->have_posts() ) : $loop->the_post(); 
    ?>

     <?php the_title(); ?>
     <?php the_content(); ?>
     <?php echo '<button class="button" data-post_id="' .$id. '">' ;?>
         <?php echo get_post_meta($post->ID, 'rh_type', true); ?>   
     <?php echo '</button>';?>  
     <div class="new_content">
          <!--Ajax new content goes here-->
     </div>
 </div>

Thus, the messages will be displayed with the title, content, buttonwith custom meta ( "rh_type"). When the button is clicked, it loads another file ( second.php) via ajax, as shown below in the new_contentdiv.

Second.php

 <div class="second_content">
     <?php the_title(); ?>
     <?php the_content(); ?>
     <?php echo get_post_meta($post->ID, 'rh_type', true); ?>   
 </div>

In other words, when pressed buttonfrom first.php, it second.phpwill be loaded into the div new_content. After downloading it, I want to do so, to display the same title, contentand custom metathat first.php.

However, there is a problem.

meta second.php ( , ), , post meta.

, "extend", .

:

  • post_id, post_id .
  • post_id ( jQuery) ( ..).
  • second.php, load paste .

, , .

.

!

:

, , , , .

, .

  • 10 .
  • "contact_form.php" ajax.
  • .
  • , , ..
  • , .

.

, .

, ​​ .

, ( ) , - , , "" , , , .

+4

Source: https://habr.com/ru/post/1607231/


All Articles