JavaScript php post content in a popup div wordpress post content popup,show post content in popup wordpress

I have several elements within a website that are linked to separate php posts. The site also has one popup div('it's a custom modal window'). The popup div has two sections, title and content.

When the elements are clicked, the popup window will appear. I want the associated php post title and content to appear in the popup div in its proper section.

NOTE: I have tried for a week to figure this out using, php, ajax/jquery, combinations. I have scoured google and stackoverflow and can't seem to find the missing link.


Below is my code structure.


FIRST: This is the closest I've got to a working model. The php post_title and post_content is added to the popup window in the appropriate place. But adding code for the next element overrides the first elements data.

HTML

<div class="hexagon">
  <p class="verticalcenter center" data-toggle="popWindow" data-target="#popUp">
    <!-- ATTACH LATEST POST TITLE -->
      <?php $the_query = new WP_Query( 'cat=4' ); ?>
      <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
        <?php the_title(); ?>
      <?php endwhile;?>
  </p> 
</div>

<div class="hexagon">
  <p class="verticalcenter center" data-toggle="popWindow" data-target="#popUp">
    <!-- ATTACH LATEST POST TITLE -->
      <?php $the_query = new WP_Query( 'cat=5' ); ?>
      <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
        <?php the_title(); ?>
      <?php endwhile;?>
   </p>
</div>

JS

Note: The 'overlay' is a background with opacity that covers the main content to help focus on the 'popUp' div.

$(document).ready(function() {
...//other code pertaining to website operation

//Click on Hexagons && Launch Modal
  $('.hexagon,.hexagonz,#mapToken,.mobileNav li').on('click', function() {
    $('.overlay').removeClass('hidden');
      $('#popUp')
        .addClass('animated fadeInUp')
        .css( {
            'bottom': '25%' 
        } )
  }); //end Modal Launch

...//other code pertaining to website operation

});// end $(document).ready

The popup window(Modal) html code is located in my footer.php file along with a single.php file containing duplicate popup window code.

IDEALLY: I'd like to accomplish this without resorting to using an (a target='_blank' href=''). This website has a splash page that loads in front of the main page on first load. When I have tried fix this using an (a target='_blank' href='') link, it triggers the splash page(not what I want).

Hope the structure and end goal are clear.

Answer:1

Why sum is undefined. What am I doing wrong? var testData1 = [{ "name": "Doctors", "category": "Doctors", "subCategory": [{ "name": "Likes", "category": "Likes", "...

Why sum is undefined. What am I doing wrong? var testData1 = [{ "name": "Doctors", "category": "Doctors", "subCategory": [{ "name": "Likes", "category": "Likes", "...

  1. recursive function returning none
  2. recursive function returning undefined
  3. recursive function returning value
  4. recursive function returning
  5. recursive function returning either
  6. recursive function output questions
  7. recursive function not returning value
  8. recursive function not returning value python
  9. javascript recursive function returning undefined
  10. recursive function not returning value php
  11. function recursive output
  12. javascript recursive function not returning
  13. recursive function returning array

I currently have three nested promises which I want to turn into a $q.all call. It looks something like this. ds.saveData(data).then(function (result1){ someOtherVar = result1.Id; ds....

I currently have three nested promises which I want to turn into a $q.all call. It looks something like this. ds.saveData(data).then(function (result1){ someOtherVar = result1.Id; ds....

I'm trying to make a tooltip using jQuery, with HTML and CSS. Each tooltip is different by the id and that works great, so I can make as many tooltips as I want and style them independently. What I ...

I'm trying to make a tooltip using jQuery, with HTML and CSS. Each tooltip is different by the id and that works great, so I can make as many tooltips as I want and style them independently. What I ...

This is my first question on Stackoverflow so please excuse any mistakes I make. I'm trying to display in the view, some HTML from a template, which I use in the following directive: app.directive('...

This is my first question on Stackoverflow so please excuse any mistakes I make. I'm trying to display in the view, some HTML from a template, which I use in the following directive: app.directive('...

  1. html user insert image