Adding Wordpress Post Title inside Popup - wordpress

Im trying to make a popup window which will display the post title and post thumbnail.
I have added this popup code into the category page template.
Basically if you click on the post title, the popup window will display showing the post thumbnail and post title, however each popup window is showing the same post details.
What changes would I need to make, so each popup window displays the corresponding post details
example. I have 3 post, titled, Post A, Post B, Post C, but in the lightbox all post titles say "Post A"
Any suggestions would be appreciated
Here is the code im using.....................
<div id="maincontainer" style="width:700px; height:auto; display:block;"><!-- Begin Main Container -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<span id="magblock"> <!-- Begin Post Block -->
<div class="magazinethumbs">
<?php
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'magazine-thumb' );
}
?>
</div>
<!-- This opens the Lightbox -->
<a class="lbp-inline-link-1 cboxElement" href="#">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</a>
</span> <!-- End Post Block-->
<div style="display: none;"> <!-- Lightbox Popup -->
<div id="lbp-inline-href-1" style="padding:10px; background: #fff;">
<!-- Here is the bug, the lightbox is loading the same post details -->
<div class="magazinethumbs">
<?php
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'magazine-thumb' );
}
?>
</div>
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</div>
</div> <!-- End Lightbox Popup -->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php wp_reset_query();?>
</div><!-- End Main container -->
Im using "Lightbox Plus For Wordpress" plugin
http://www.endocreative.com/how-to-insert-content-in-a-popup-using-lightbox-plus-for-wordpress/
I tried your modified code but did not work... Simply loads the entire category page inside the lightbox...
Here is the modified code
<a class="lbp-inline-link-<?php the_ID(); ?> cboxElement" href="#">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</a>
<div style="display: none;"> <!-- begin popup -->
<div id="lbp-inline-href-<?php the_ID(); ?>" style="padding:10px; background: #fff;">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</div>
</div> <!-- End popup -->
Thanks

I may be sleeping when you answer my comment, so.
You have to do the step 2 of that tutorial, it will give you Inline Lightbox Individual Settings.
it'll give you a sequential classes
lbp-inline-link-1 for lbp-inline-href-1,
lbp-inline-link-2 for lbp-inline-href-2 and so on..
before
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
insert:
<?php
$i = 1;
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
in the place of:
<a class="lbp-inline-link-1 cboxElement" href="#">
put
<a class="lbp-inline-link-<?php echo $i;?>" href="#">
do the same for the:
<div id="lbp-inline-href-1" style="padding:10px; background: #fff;">
put
<div id="lbp-inline-href-<?php echo $i; ?>" style="padding:10px; background: #fff;">
and before the endwhile put
<?php
$i++;
endwhile; else: ?>
OBS: you have to set the number os posts being show the same number of the "Number of Inline Lightboxes::"
Eg.: If the post list will show, 10 posts per page, on step 2 "Number of Inline Lightboxes::" you have to set to 10.

Related

Wordpress hierarchy issue with categorized post not using specific template

I'm trying to implement a dedicated template for any post with a category slug of 'rentals'. There are posts in the database with a category of rentals set up and applied. I've created the template with a standard loop and called it category-rentals.php, saving it in my root folder.
It's just not working. It keeps reverting to single post template (index.php specifically).
My rendered body classes are as such:
post-template-default single single-post postid-278 single-format-standard
Am I missing a step here?
category-rentals.php:
/*
* Rental property template
*/
?>
<?php get_header(); ?>
<div class="jumbotron jumbotron-fluid" style="background-image: url('<?php bloginfo( 'template_url' ); ?>/img/bg-semi-trans.png'), url('<?php bloginfo( 'template_url' ); ?>/img/bg-jumbotron.jpg');">
<div class="container">
<div class="headline text-center animated fadeInUp">
<p><?php wp_title(''); ?></p>
</div>
</div>
</div>
<section>
<div class="container">
<div class="row">
<div class="col-12">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else : ?>
<p><?php esc_html_e( 'Sorry, no content matched your criteria.' ); ?></p>
<?php endif; ?>
<hr>
← Go Back | Contact Us
</div>
</div>
</div>
</section>
<?php get_footer(); ?>

How do I add a page featured image to nivo slider in wordpress?

I've followed the guide below in trying to manually install nivo slider into Wordpress: http://www.aoclarkejr.com/author/aj/
I'm trying to get the slider to pick up and display the featured image. I think perhaps there is a problem with the code in step 6, and not just the missing ' (see below). As the slider appears to be loading i.e I get the next/prev tabs and can see the code when viewing the page source, but it's not picking up and displaying the featured image.
<div id="slider-wrap">
<div id="slider">
<?php query_posts(array(
'post_type'=>'slides
));
?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post();
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
?>
<img src="<?php echo $thumbnail[0]; ?>" width="" height="" />
<?php endwhile; ?>
</div><!--/slider nivoSlider-->
</div><!--/slider-wrap -->
I should add that I'm trying to get this to work on a page, not custom post.
My ultimate goal is the get the same implementation as this: http://pexetothemes.com/demos/story_wp/home-default/
Here is my code now:
<?php get_header(); ?>
<div class="header-wrapper">
<div id="slider-wrap">
<div id="slider">
<?php query_posts(array(
'post_type'=>'page'
));
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
?> <img src="<?php echo $thumbnail[0]; ?>" width="" height="" />
<?php // endwhile; ?>
</div><!--/slider nivoSlider-->
</div><!--/slider-wrap -->
</div>
<div class="clear"></div>
<div id="content-container" class="content-boxed layout-full">
<div id="full-width" class="content">
<div class="content-box">
<?php the_content(); ?>
</div>
</div>
</div>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div><!-- page wrapper -->
<?php get_footer(); ?>
For some reason part of the page is repeating itself.
<div class="header-wrapper"></div>
<div id="slider-wrap">
<div id="slider">
<img width="" height="" src="http://localhost:8888/defylife/assets/images/posts/ccm_adventure_450gp_left.jpg"></img>
</div>
<!--
/slider nivoSlider
-->
</div>
<!--
/slider-wrap
-->
<div class="clear"></div>
<div id="content-container" class="content-boxed layout-full">
<div id="full-width" class="content">
<div class="content-box"></div>
</div>
</div>
<img width="" height="" src=""></img>
</div>
<!--
/slider nivoSlider
-->
</div>
<!--
/slider-wrap
-->

Loading wordpress posts after user clicks anchor

This is my tab menu, where user can select tab
<div id="slider-menu" class="row">
<div class="span12">
<ul class="nav nav-tabs" id="myTab">
<li class="active">Latest events<div class="triangle"></div></li>
<li>Our champions</li>
<li>We have puppies!</li>
</ul>
</div>
</div>
And there are my tabs, in which content is loaded when page loads
<div class="tab-content">
<div class="tab-pane active" id="home">
<img src="<?php bloginfo('template_url'); ?>/img/slider.png" />
<div class="span12">
<?php
query_posts('cat=7');
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div>
</div>
<div class="tab-pane" id="profile">
<img src="<?php bloginfo('template_url'); ?>/img/slider.png" />
<div class="span12">
<?php
query_posts('cat=8');
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div>
</div>
<div class="tab-pane" id="messages">
<img src="<?php bloginfo('template_url'); ?>/img/slider.png" />
<div class="span12">
<?php
query_posts('cat=9');
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div>
</div>
</div>
When there will be a lot of posts, it will take page to load too long, so my basic idea is to load all posts to the first tab when page loads, and load posts to another tab when user selects it.
I struggle how to combine wp posts loop and ajax to load posts when user clicks specific tab.
Thank you for your help in advance.
$.ajaxSetup({cache:false});
$('#myTab li').click(function(){
var cat_id = $(this).children().attr('rel');
$.get('location.href' + cat_id, function(data) {
$('#' + cat_id).html(data);
return false;
});
So I output category id to anchor rel attribute, then I add click event handler in which I call .get function. After all, I output data.

Open a custom link in a modal when fetching posts from wordpress

What I am trying to achieve is to create a grid with bootstrap inside a wordpress page and display 30 posts as thumbnails. By clicking on the thumbnail a modal box will be displayed with the image in full size.
What am I doing right now is that the modal pops up but displays the same image every time. I am trying to set the href value in the tag that will display the of the post in the modal.
<?php get_header(); ?>
<div id="content" class="clearfix">
<div id="main" class="clearfix" role="main">
<?php $counter = 0; ?>
<div class="row-fluid">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php if ($counter < 4): ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix thumbnail-post span3'); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
<header>
<a href="#myModal" data-toggle="modal" >
<?php the_post_thumbnail( 'graphix-thumbnail' ); ?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
</a>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class='modal-body'>
<img src="<?php echo $url; ?>" />
</div>
</div>
<div class="page-header"><h3 itemprop="headline"><?php the_title(); ?></h3></div>
</header> <!-- end article header -->
<section class="post_content clearfix">
<?php the_content(); ?>
</section>
</article> <!-- end article -->
<?php $counter +=1; ?>
<?php else: ?>
</div>
<?php $counter = 0; ?>
<div class="row-fluid">
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
</div>
<?php endif; ?>
</div> <!-- end #main -->
</div> <!-- end #content -->
<?php get_footer(); ?>
See this question. Its pretty easy to pass data to a modal with jQuery.
What I did wrong was that the modal's identifier was the same and the id has to be unique. So I changed the id of the modal to "#myModal-" and each one got its own unique id !

Facebook like button reacts on all posts

I think something's wrong with my query I'm using below. I want to show multiple thumbnails with each its own like button. All works fine, but when you press 1 button, it will like all other images as well. Tried the reset query, but I guess it's not working or I got things wrong. Someone got a simular problem or knows how to fix this?
<?php query_posts('cat=1'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php $thumb = get_post_meta($post->ID, 'thumb', $single = true); ?>
<ul>
<li>
<img src="<?php echo $thumb; ?>" alt="View <?php the_title_attribute(); ?>'s showcase" width="150" height="111" />
<div class="design"><?php the_title(); ?></div>
<div class="subtitle">view feature</div>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
</div>
<!-- AddThis Button END -->
</li>
</ul>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php wp_reset_query() ?>
Add a fbml href attribute to the like button.
<a class="addthis_button_facebook_like" fb:like:layout="button_count" fb:like:href="<?php the_permalink(); ?>"></a>

Resources