hej myran
i think i have some kind of the same issue.
I also want do display a post using javascript, but on the same site.
The problem is, that i can’t figure out, how to tell wordpress to show one post, without changing all the site.
I think, that the information, which post to display is coming from the URL(p.e: /wordpress/?p=201 –> post with ID 201 is shown).
So I want to tell functions like the_content() (which is creating the post) via javascript another value for “p”.
Unfortunately I did not figure out, how to do this. Maybe someone else can help.
Thread Starter
mYrAn
(@myran)
Yeah, i think we’re trying to achive the same thing! Like a lightbox with the content in.
Thread Starter
mYrAn
(@myran)
I have now found the solution! Here’s how to do it for everybody that wants to do simular things. Im using ajax to get the info, and fancybox to display it. Initiate fancybox the usual way.
Where the content should be displayed you do like this:
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<a href="<?php the_permalink() ?>" class="popup" title="<?php the_title(); ?>">Popup</a>
Add this to the head:
<script type="text/javascript">
$(document).ready(function() {
$(".popup").fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade'
});
});
</script>
I think that’s right. Remember to make it a class, otherwise it will only show up in one post. Then you edit single.php to display what you want.
Hi do you think you could make a tutorial and post it somewhere with a few screenshots? If it’s not too much to ask, so that newbies like me can benefit from this. Thanks