1 Replies - 2819 Views - Last Post: 15 November 2013 - 10:20 PM

#1 floppyspace  Icon User is offline

  • D.I.C Regular

Reputation: 48
  • View blog
  • Posts: 254
  • Joined: 04-February 10

modal show same content in wordpress theme

Posted 14 November 2013 - 03:00 AM

Hi,

So I kind of know what the issue is but need some assistance, it is more jquery related but because it is wordpress I felt here would be the best place to post it.

I was playing with wordpress and modal and have been able to get the posts to pop up in a modal, now the issue is that for a single post page my code works fine because I am using the get_page_by_title and the page will show in the modal as I want it too. However when I use a loop the modal will list the various posts but when clicked the link will show the same modal (same instance,the first one created).

I am using this line which works fine
<?php if ( is_singular() ) {echo '<h1 class="entry-title">';} else {echo '<h2 class="entry-title">';} ?><a href="<?php get_permalink( get_page_by_title(  the_title(the_permalink()) ) ) ; ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a><?php if ( is_singular() ) {echo '</h1>';} else {echo '</h2>';} ?> <?php edit_post_link(); ?>



But what I need to do is after each link/modal is created I need to destroy or remove the data that is in the modal, so when the above code runs it uses an empty modal.

I found this link to be a possible solution (although it is not directly related the the jqueryui library that I am using)

Same content every time

But after a few attempts it still brings up the same post in the modal.

Any suggestions would be appreciated.

removeData jquery - this is something I am planning to try but I am not too familiar with it and have yet to decipher how it works, any advice or a more easier to read version that anyone knows of?

Is This A Good Question/Topic? 0
  • +

Replies To: modal show same content in wordpress theme

#2 floppyspace  Icon User is offline

  • D.I.C Regular

Reputation: 48
  • View blog
  • Posts: 254
  • Joined: 04-February 10

Re: modal show same content in wordpress theme

Posted 15 November 2013 - 10:20 PM

So I solved the problem and felt I should post it for others who may attempt to do the same.
By adding the <?php the_title(); ?> to the script and to the modal open boxes it allowed unique ids for each modal window.


<script>
  $(function() {
    $( "#dialog-modal<?php the_title(); ?>" ).dialog({
      height: 330,
      modal: true
    });
  });
  </script>


<div id="openModal2<?php the_title(); ?>" class="dialog-modal">

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1