Home get a post based on another post in wordpress
Reply: 0

get a post based on another post in wordpress

Neeraj Verma
1#
Neeraj Verma Published in 2018-01-13 02:59:00Z

I am trying to create game in which one Question post should Map to one answer post in same category .

I have created a html5 table and tried to bind question post and answer post in data-question and data-answer attribute

    <div >
    <table>
    <tr> 

    <?php foreach($categories as $category) {?>
    <td>

    <?php  
    $args= array( 'posts_per_page' => 8, 'category_name' => $category-name);
      $myposts = get_posts( $args );
      ?>
      <table border=1>
      <thead><?php echo $category->name ?></thead>
      <?php
     foreach ( $myposts as $post ) : setup_postdata( $post );
        if (have_posts()) {
        ?>
        <tbody>

    <tr>

    <td data-points="<?php echo $points ;?>"                                data-question="<?php echo get_the_content(); ?>"
                            data-answer="<?php echo get_the_content(); ?>"
                            >                       
</td>

</tr>

    </tbody>                    

        <br/>
        <?php
      endforeach;
       ?></table><?php
      wp_reset_postdata();
    ?>

  <?php }?>
  </td></tr>

  </div>

I am stuck at here

<td data-points="<?php echo $points ;?>"                                data-question="<?php echo get_the_content(); ?>"
                        data-answer="<?php echo get_the_content(); ?>"
                        >                       

how can I bind data-answer to a related answer post ? Any alternate logic I can apply ?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.336254 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO