Support » Plugins » Hacks » Post Content to show in Fancy Box

  • Hi

    I have an interactive map powered by Jquery and I want to be able to show a list of post types per region. When you click on the post type title I want a fancybox to open with the post content. For some reason I can’t see away to add the fancybox to the permalinks.

    My code is as follows:

    <script type="text/javascript">


    <li id="midlands">
    <?php page_query = new WP_Query('category_name=midlands&post_per_page>=1') while ($page_query->have_posts()): $page_query->the_post();?>
    <a class="fancybox" href="<?php the_permalink();?>"<?php the_title();?>?><?php the_title();?</a><br/>
    <?php endwhile: wp_reset_postdata();?></li>

    I have tried everything and I can not get it to work. I can get a link without a permalink to display the page content the links on but I not able to pull the content from a post.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thea G


    For one thing, try to echo your variables so they get written to the html like this

    <?php echo the_permalink();?>

    Moderator bcworkz


    @thea G: That’s a good tip in general, except for WP functions with names starting with “the_”, which typically directly echo content to the client as part of the function and do not actually return anything. So the code you suggest will not do anything more than the OP’s code. the_permalink() is a one liner function, essentially: echo get_the_permalink();

    @cocoonfz: The first snippet has a selector with a missing quote, but I suspect it’s a typo and not the cause of your problem. I don’t have a real solution for you, but where your script appears in the header can make a difference, which is sometimes not entirely controllable. You might try enqueuing the script and relevant css so WP knows about it and hopefully resolves dependencies. I don’t know if this will help, but would be worth a try if you’re still stuck.

    Thea G


    thanks bcworkz…I didn’t know that (about the echo being built into the_ functions). It makes sense that is how it works …the_content() et al

    I need just exactly what cocoonfx was talking about, but I’m not so good in program. Can anyone explain me how can I link my posts to this query page??
    I’m working with custom post types

    <?php page_query = new WP_Query(‘category_name=midlands&post_per_page>=1’) while ($page_query->have_posts()): $page_query->the_post();?>

    thank you so much!!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post Content to show in Fancy Box’ is closed to new replies.