Infinite scrolling repeats... I have no idea why - php

I'm modifying a wordpress site that's got the iPin theme (pinterest-style infinite scrolling theme) installed.
I want the first four "pins" to show specific links, and then after that for all the "pins" to be the natural flow of blog posts.
Instead, the first four are successfully displaying how I want, but then when you scroll down and the site load more pins, those same 'specific link' pins come up again, and then again when you scroll down again.
This is the page I'm working with (please excuse the messiness - early stages of construction)
I tried making a string that changes once the four links are displayed and basically says "if it has changed don't show the links" but that didn't work at all.
Can anyone help me?
Thanks in advance - here's the total code from my index.php:
<?php get_header(); ?>
<div class="container-fluid" style="width: 1100px; margin-left:auto; margin-right: auto;">
<div id="ajax-loader-masonry" class="ajax-loader"></div>
<div id="masonry">
<?php //"create a pod about yourself" link <=====this is the first 'specific link' pin
?>
<div style="overflow:hidden; width: 220px; height:100px; padding:0px;background-color:#DDD;" <?php post_class('thumb');?> >
<div class="thumb-holder">
<a href="create-a-pod-about-yourself" class="create-a-pod-about-yourself-link-pod" style="padding:7px;">
<p class="create-a-pod-about-yourself-link-pod">Add pod:<br/>Introduce yourself<br/><br/></p></a>
</div>
</div>
<?php //"create a project pod" link <=====this is the second 'specific link' pin
?>
<div style="overflow:hidden; width: 220px; height:100px; padding:0px;background-color:#DDD;" <?php post_class('thumb');?> >
<div class="thumb-holder">
<a href="create-a-project-pod" class="create-a-project-pod-link-pod" style="padding:7px;">
<p class="create-a-project-pod-link-pod">Add pod:<br/>Promote a project<br/><br/></p></a>
</div>
</div>
<?php //"create an idea pod" link <=====this is the third 'specific link' pin
?>
<div style="overflow:hidden; width: 220px; height:100px; padding:0px;background-color:#DDD;" <?php post_class('thumb');?> >
<div class="thumb-holder">
<a href="create-an-idea-pod" class="create-an-idea-pod-link-pod" style="padding:7px;">
<p class="create-an-idea-pod-link-pod">Add pod:<br/>Share an idea<br/><br/></p></a>
</div>
</div>
<?php //"create a question pod" link <=====this is the fourth 'specific link' pin
?>
<div style="overflow:hidden; width: 220px; height:100px; padding:0px;background-color:#DDD;" <?php post_class('thumb');?> >
<div class="thumb-holder">
<a href="create-a-question-pod" class="create-a-question-pod-link-pod" style="padding:7px;">
<p class="create-a-question-pod-link-pod">Add pod:<br/>Ask a question<br/><br/></p></a>
</div>
</div>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php //====now begins the infinitely scrolling list of normal blog posts
?>
<div id="post-<?php the_ID(); ?>"<?php post_class('thumb');?> style="padding:0px; background-color:
<?php $category = get_the_category($postID);
foreach (get_the_category() as $category) {
if($category->name=='People'){
echo '#FCC';
}
else if($category->name=='Projects'){
echo '#CCF';
}
else if($category->name=='Ideas'){
echo '#CFC';
}
}
?>
;">
<div class="thumb-holder">
<?php// if($category->name=='People'){
?>
<div class="masonry-actionbar">
<a class="btn btn-mini" href="<?php the_permalink(); ?>/#respond"><i class="icon-comment"></i> <?php _e('Comment', 'ipin'); ?></a>
<a class="btn btn-mini" href="<?php the_permalink(); ?>"><?php _e('View', 'ipin'); ?> <i class="icon-arrow-right"></i></a>
</div>
<a href="<?php the_permalink(); ?>">
<?php
if (has_post_thumbnail()) {
$imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'medium');
$imgwidth = $imgsrc[1];
$imgheight = $imgsrc[2];
$imgsrc = $imgsrc[0];
} elseif ($postimages = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=0")) {
foreach($postimages as $postimage) {
$imgsrc = wp_get_attachment_image_src($postimage->ID, 'medium');
$imgwidth = $imgsrc[1];
$imgheight = $imgsrc[2];
$imgsrc = $imgsrc[0];
}
} elseif (preg_match('/<img [^>]*src=["|\']([^"|\']+)/i', get_the_content(), $match) != FALSE) {
$imgsrc = $match[1];
} else {
$imgsrc = get_template_directory_uri() . '/img/blank.gif';
}
?>
<img src="<?php echo $imgsrc; $imgsrc = ''; ?>" alt="<?php the_title_attribute(); ?>" style="<?php if ($imgwidth != '') { ?>width:220px;height:<?php echo round(220/$imgwidth*$imgheight); ?>px;<?php } else { ?>width:220px;height:220px;<?php } ?>" />
</a>
</div>
<div class="thumbtitle" style="font-size:16px; font-weight: bold; COLOR:#ee4949;"><?php the_title(); ?></div>
<div class="thumbtitle"><?php the_content(); ?></div>
<div class="masonry-meta<?php $show_avatars = get_option('show_avatars'); $comments_number = get_comments_number(); if ($comments_number == 0 && $show_avatars == '0') { echo ' text-align-center'; } ?>">
<?php if ($show_avatars == '1') { ?>
<div class="masonry-meta-comment">
<?php } ?>
<span class="masonry-meta-content" style="font-size:15px;"><?php the_category(', '); ?></span>
<?php if ($show_avatars == '1') { ?>
</div>
<?php } ?>
</div>
<?php
if ('0' != $frontpage_comments_number = of_get_option('frontpage_comments_number')) {
$args = array(
'number' => $frontpage_comments_number,
'post_id' => $post->ID,
'status' => 'approve'
);
$comments = get_comments($args);
foreach($comments as $comment) {
?>
<div class="masonry-meta">
<?php if ($show_avatars == '1') { ?>
<div class="masonry-meta-avatar"><?php echo get_avatar( $comment->comment_author_email , '30'); ?></div>
<div class="masonry-meta-comment">
<?php } ?>
<span class="masonry-meta-author"><?php echo $comment->comment_author; ?></span>
<?php echo $comment->comment_content; ?>
<?php if ($show_avatars == '1') { ?>
</div>
<?php } ?>
</div>
<?php
}
if ($comments_number > $frontpage_comments_number) {
?>
<div class="masonry-meta text-align-center">
<span class="masonry-meta-author">
<?php _e('View all', 'ipin'); ?> <?php echo $comments_number; ?> <?php _e('comments', 'ipin') ?>
</span>
</div>
<?php }
} ?>
</div>
<?php
endwhile;
else :
?>
<div class="row-fluid">
<div class="span3"></div>
<div class="span6">
<div class="post-wrapper">
<div class="h1-wrapper">
<h1><?php _e( 'No Items Found', 'ipin' ); ?></h1>
</div>
<div class="post-content text-align-center">
<p><?php _e('Perhaps searching will help.', 'ipin'); ?></p>
<?php get_search_form(); ?>
</div>
</div>
</div>
<div class="span3"></div>
</div>
<?php endif; ?>
</div>
<div id="navigation">
<ul class="pager">
<li id="navigation-next"><?php next_posts_link(__('« Previous', 'ipin')) ?></li>
<li id="navigation-previous"><?php previous_posts_link(__('Next »', 'ipin')) ?></li>
</ul>
</div>
<div id="scrolltotop"><i class="icon-chevron-up"></i><br /><?php _e('Top', 'ipin'); ?></div>
</div>
<?php get_footer(); ?>

Related

How to show first post differently from other posts?

I created the design that will be used to show first post differently from the others. It's not that easy because the first post needs to be in his own div id, which is completely different from the other posts.
Here is the code I currently use in wordpress php:
<?php get_header(); ?>
<!-- Begin Content -->
<div id="content-wide">
<div class="post">
<div class="imgwide" style="background: linear-gradient(to bottom, rgba(0,0,0,0) 60%, rgba(0,0,0,0.8)), url(<?php echo catch_that_image() ?>); background-repeat: no-repeat; background-size: 100%; background-position: center;">
<div class="p-heading">
<h1>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</h1>
<div class="p-content">
Excerpt text of the first post goes here but php the_excerpt doesnt work for this wide paragraph
</div>
</div>
</div>
</div>
</div>
<div id="content-a">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post">
<div class="imgdiv"><img src="<?php echo catch_that_image() ?>" width="250"></div>
<div class="p-heading">
<h1>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</h1>
</div>
<div class="p-content">
<?php the_excerpt(); ?>
</div>
<div class="p-info">
<?php the_time('j.m.Y') ?> |
<?php the_category(', '); ?> | <img src="http://www.virmodrosti.com/wp-content/uploads/comments.png" alt="Komentarji" width="26" height="12">
<?php $totalcomments = get_comments_number(); echo $totalcomments; ?>
</div>
</div>
<?php endwhile; ?>
and here is my site url http://www.virmodrosti.com/zdravje/
All I want is that first post isn't displayed twice, but is only moved to the wide post design. The big post is in content-wide. Let me know how to do that. Thank you.
try to add a counter that starts in zero and increment it inside your while loop, then use if else statement to check the value of counter if zero display the first post else the other posts.
EDITED
<?php $counter = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php if($counter == 0) { ?>
<div id="content-wide">
<div class="post">
<div class="imgwide" style="background: linear-gradient(to bottom, rgba(0,0,0,0) 60%, rgba(0,0,0,0.8)), url(<?php echo catch_that_image(); ?>); background-repeat: no-repeat; background-size: 100%; background-position: center;">
<div class="p-heading">
<h1><?php the_title(); ?></h1>
<div class="p-content">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php if($counter > 0) { ?>
<div class="post">
<div class="imgdiv"><img src="<?php echo catch_that_image() ?>" width="250"></div>
<div class="p-heading">
<h1><?php the_title(); ?></h1></div>
<div class="p-content">
<?php the_excerpt(); ?>
</div>
<div class="p-info">
<?php the_time('j.m.Y') ?> |
<?php the_category(', '); ?> | <img src="http://www.virmodrosti.com/wp-content/uploads/comments.png" alt="Komentarji" width="26" height="12">
<?php $totalcomments = get_comments_number(); echo $totalcomments; ?>
</div>
</div>
<?php } ?>
<?php $counter ++; ?>
<?php endwhile; ?>

How Do I Add More Latest Post To Homepage

I can work pretty good with CSS and HTML but know nothing about PHP. I'm working on a wordpress client project and he wants more than one Latest Post/Recent Post to display on the static homepage. I'm pulling my hair out trying to figure this out. From the posted code, can someone show me what to delete and what to replace it with to make 5 of the most latest post appear? I really appreciate everyone's help.
<?php
/**
* Template Name: Homepage
*/
?>
<?php $mts_options = get_option(MTS_THEME_NAME); ?>
<?php get_header(); ?>
<?php if ($mts_options['mts_banner_show'] == '1') { ?>
<div class="b_first">
<div class="main-container">
<div class="container">
<div class="blog_first">
<!--first content-->
<div id="first_b">
<div class="b_right" <?php if ( isset( $_GET['mailchimp_signup'] ) || !empty( $_GET['aweber_signedup'] ) ) echo 'style="display:none;"'; ?>>
<h2 class="front-view-title">
<?php echo $mts_options['mts_banner_title']; ?>
</h2>
<div class="front-view-content">
<?php echo $mts_options['mts_banner_texts']; ?>
</div>
<?php if(!empty($mts_options['mts_button_text'])) { ?>
<div class="readMore" style="background:<?php echo $mts_options['mts_banner_button_bg']; ?>">
<?php echo $mts_options['mts_button_text']; ?>
<?php if(!empty($mts_options['mts_arrow_image'])) { ?>
<div class="b_dollor">
<img src="<?php echo $mts_options['mts_arrow_image']; ?>">
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<!--Rightside Content-Option-1-->
</div>
<div id="second_b" <?php if ( !isset( $_GET['mailchimp_signup'] ) && empty( $_GET['aweber_signedup'] ) ) echo 'style="display:none;"'; ?>>
<div class="blog_first_alternative">
<h2 class="front-view-title">
<?php echo $mts_options['mts_banner_title']; ?>
</h2>
<div class="form_wrap">
<?php if(!empty($mts_options['mts_form_image'])) { ?>
<div class="form_wrap_left">
<img src="<?php echo $mts_options['mts_form_image']; ?>">
</div>
<?php } ?>
<div class="form_wrap_right">
<?php dynamic_sidebar('Home Subscribe Widget'); ?>
</div>
</div>
</div>
<!--Rightside content alternative option-->
<script type="text/javascript">
function hide_b() {
jQuery('#first_b').hide();
jQuery('#second_b').show();
}
</script>
</div>
</div>
<!--End of first content-->
</div>
</div>
</div>
<?php } ?>
<div class="main-container">
<div id="page">
<div class="artcl article">
<div id="content_box">
<?php if ($mts_options['mts_banner2_show'] == '1') { ?>
<!--Second Content-->
<div class="blog_second">
<div class="b_left">
<h2 class="front-view-title">
<?php echo $mts_options['mts_social_title']; ?>
</h2>
<?php if ( !empty($mts_options['mts_banner_social']) && is_array($mts_options['mts_banner_social'])) { ?>
<div class="social-icons">
<ul>
<?php foreach( $mts_options['mts_banner_social'] as $header_icons ) : ?>
<?php if( ! empty( $header_icons['mts_banner_icon'] ) && isset( $header_icons['mts_banner_icon'] ) ) : ?>
<li><span class="fa fa-<?php print $header_icons['mts_banner_icon'] ?>"></span></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php } ?>
</div>
<div class="b_right">
<h2 class="front-view-title">
<?php echo $mts_options['mts_books_title']; ?>
</h2>
<div class="b_readings">
<ul>
<?php if(!empty($mts_options['mts_books_image'])){ ?>
<?php foreach( $mts_options['mts_books_image'] as $slide ) : ?>
<li> <?php echo wp_get_attachment_image( $slide['mts_book_image'], false, array('title' =>'') ); ?></li>
<?php endforeach; ?>
<li class="more-books"><?php echo $mts_options['mts_more_book_text']; ?><i class="fa fa-angle-double-right"></i></li>
<?php } ?>
</ul>
</div>
</div>
</div>
<?php } ?>
<?php if(!empty($mts_options['mts_featured_posts']) && !empty($mts_options['mts_featured_post_cat'])) { ?>
<div class="home_article">
<?php
$featured_cat = implode( ",", $mts_options['mts_featured_post_cat'] );
$featured_query = new WP_Query('cat='.$featured_cat.'&posts_per_page=5');
if ($featured_query->have_posts()) : while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?>
<article class="latestPost featuredpost excerpt">
<!--Featured Post-->
<header>
<h3 class="title front-view-title"><?php echo get_the_category_by_ID($featured_cat); ?></h3>
<?php if(has_post_thumbnail()) { ?>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" id="featured-thumbnail">
<div class="featured-thumbnail">
<?php the_post_thumbnail('steadyincome-featured',array('title' => '')); ?> <?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'latestPost-review-wrapper'); ?>
</div>
</a>
<?php } ?>
</header>
<div class="latestpost_wrap">
<h2 class="front-view-title">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>
"><?php the_title(); ?></a>
</h2>
<?php mts_the_postinfo( 'home' ); ?>
<div class="front-view-content">
<?php echo mts_excerpt(45); ?>
</div>
<?php mts_readmore(); ?>
</div>
</article>
<?php endwhile; wp_reset_query(); endif; ?>
<?php $j = 0;
if (get_query_var('page') > 1) {
$paged = get_query_var('page');
} elseif (get_query_var('paged')) {
$paged = get_query_var('paged');
} else {
$paged = 1;
}
$args= array('paged' => $paged, 'post_type' => 'post');
query_posts($args);
if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<?php if($j ==0){ ?>
<article class="latestPost latestpost excerpt">
<!--Latest Post-->
<header>
<h3 class="title front-view-title"><?php _e('Latest Post','steadyincome'); ?></h3>
<a href="<?php the_permalink() ?>" title="Menu widget article" id="featured-thumbnail">
<div class="featured-thumbnail">
<?php the_post_thumbnail('steadyincome-featured',array('title' => '')); ?>
<?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'latestPost-review-wrapper'); ?>
</div>
</a>
</header>
<div class="latestpost_wrap">
<h2 class="front-view-title">
<?php the_title(); ?>
</h2>
<?php mts_the_postinfo( 'home' ); ?>
<div class="front-view-content">
<?php echo mts_excerpt(40); ?>
</div>
<?php mts_readmore(); ?>
</div>
</article>
<?php } ?>
<?php $j++; endwhile; wp_reset_query(); endif; ?>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Looks like you might have some setting in your theme settings. However if you have no setting there.
You can see this line that is limiting latest posts to just one Post:
<?php if($j ==0){ ?>
You may try to change it to number you want to try and see if it loops more posts there:
<?php if($j < 5){ ?>
This should allow the loop to run for five posts now. Give it a try and see if it helps.

Only first posts featured image is shown

I am creating a custom template for WordPress. I can add multiple featured images in a single post and can show them as a gallery or slider.
Everything works fine on the first post.
When I add my second post with 2 or more featured images it does not display any image at all if I have only 1 featured image it shows.
Can anyone review my code and tell me what am I missing:
EDIT
<?php /* Template Name: Home v4 */ get_template_part('/template-parts/home4_header'); ?>
<section class="background-color">
<?php query_posts('showposts=0'); ?>
<?php $i = 1; ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if(($i % 4) !== 0) { ?>
<!-- Fixed width banner -->
<div class="container">
<div class="containerBox">
<!-- Multiple Featured Images Slider -->
<?php
if (class_exists('MultiPostThumbnails')) {
// Loops through each feature image and grabs thumbnail URL
$x=1; $image1_id; $image2_id; $image3_id; $image4_id; $image5_id;
while ($x<=5) {
$image_name = 'feature-image-'.$x; // sets image name as feature-image-1, feature-image-2 etc.
if (MultiPostThumbnails::has_post_thumbnail('post', $image_name)) {
$image_id = MultiPostThumbnails::get_post_thumbnail_id( 'post', $image_name, $post->ID ); // use the MultiPostThumbnails to get the image ID
$image_thumb_url = wp_get_attachment_image_src( $image_id,'small-thumb'); // define thumb src based on image ID
$image_feature_url = wp_get_attachment_image_src( $image_id,'feature-image' ); // define full size src based on image ID
$attr = array(
'rel' => $image_thumb_url[0], // sets the url for the image thumbnails size
'src' => $image_feature_url[0], // sets the url for the full image size
);
// Use wp_get_attachment_image instead of standard MultiPostThumbnails to be able to tweak attributes
$image = wp_get_attachment_image( $image_id, 'feature-image', false, $attr );
//echo $image;
if ($x == 1) {$image1_id = $image_id;}
if ($x == 2) {$image2_id = $image_id;}
if ($x == 3) {$image3_id = $image_id;}
if ($x == 4) {$image4_id = $image_id;}
if ($x == 5) {$image5_id = $image_id;}
}
$x++;
}
}; // end if MultiPostThumbnails
if (!empty($image2_id)) { ?>
<div class="multi-thumb">
<div id="ninja-slider">
<div class="slider-inner">
<ul>
<li>
<div class="slider">
<?php the_post_thumbnail('full'); ?>
</div>
</li>
<li>
<div class="slider">
<img src="<?php echo wp_get_attachment_image( $image2_id, 'feature-image', false, $attr );?>">
</div>
</li>
<?php if (!empty($image3_id)) { ?>
<li>
<div class="slider">
<img src="<?php echo wp_get_attachment_image( $image3_id, 'feature-image', false, $attr );?>">
</div>
</li>
<?php } ?>
<?php if (!empty($image4_id)) { ?>
<li>
<div class="slider">
<img src="<?php echo wp_get_attachment_image( $image4_id, 'feature-image', false, $attr );?>">
</div>
</li>
<?php } ?>
<?php if (!empty($image5_id)) { ?>
<li>
<div class="slider">
<img src="<?php echo wp_get_attachment_image( $image5_id, 'feature-image', false, $attr );?>">
</div>
</li>
<?php } ?>
</ul>
<div class="fs-icon" title="Expand/Close"></div>
</div>
</div>
</div>
<?php
unset($image1_id, $image2_id, $image3_id, $image4_id, $image5_id, $image_name, $image, $image_thumb_url, $image_feature_url);
} else { the_post_thumbnail('full'); } ?>
<!-- End Multiple Featured Images Slider -->
</div>
<div class="post-area-category container-post-color bottom-padding">
<div class="content-block w-clearfix">
<div class="category">
<h5><?php echo the_category();?></h5>
</div>
<h1 class="black mastheading-post-v3"><?php the_title(); ?></h1>
<div class="date-block-v3 w-container">
<div class="black mini-date"><?php echo get_the_date(); ?></div>
<img class="mini-icon" src="<?php echo get_template_directory_uri() . '/images/comment-icon.png' ?>">
<div class="black mini-date">
<?php
$comments_count = wp_count_comments();
echo $comments_count->approved;
?>
</div>
<img class="mini-icon" src="<?php echo get_template_directory_uri() . '/images/heart-icon.png' ?>">
<div class="black mini-date">14</div>
</div>
<div class="black iltalica"><?php the_excerpt(); ?></div>
<a class="a8 cta-home-category w-button" href="<?php the_permalink(); ?>">continue reading</a>
</div>
</div>
<div class="space-4 background-color"></div>
</div>
<!-- Fixed width banner -->
<?php } elseif (($i % 4) == 0) { ?>
<!-- Full width banner -->
<div class="container-fluid">
<div class="containerBox">
<div class="home-v3-full-banner">
<?php the_post_thumbnail('full'); ?>
</div>
</div>
</div>
<div class="container post-area-category container-post-color bottom-padding">
<div class="content-block w-clearfix">
<div class="category">
<h5><?php echo the_category();?></h5>
</div>
<h1 class="black mastheading-post-v3"><?php the_title(); ?></h1>
<div class="date-block-v3 w-container">
<div class="black mini-date"><?php echo get_the_date(); ?></div>
<img class="mini-icon" src="<?php echo get_template_directory_uri() . '/images/comment-icon.png' ?>">
<div class="black mini-date">
<?php
$comments_count = wp_count_comments();
echo $comments_count->approved;
?>
</div>
<img class="mini-icon" src="<?php echo get_template_directory_uri() . '/images/heart-icon.png' ?>">
<div class="black mini-date">14</div>
</div>
<div class="black iltalica"><?php the_excerpt(); ?></div>
<a class="a8 cta-home-category w-button" href="<?php the_permalink(); ?>">continue reading</a>
</div>
</div>
</div>
<!-- End Full width banner -->
<?php } ?>
<?php $i++; ?>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
<?php wp_reset_query(); ?>
</section>
<?php get_footer(); ?>
Try this code. Not tested
<?php query_posts('showposts=0'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php $i = 1; ?>

Shortcode is moving the_content outside of the article container in WordPress

I've made a shortcode function that returns some Advanced Custom Fields depending on which repeater field is chosen. It displays correctly and in the right order however any content typed underneath the shortcode is moved outside of its <article> container element.
Here is the code:
function boxes_shortcode($atts, $content = null) {
ob_start(); ?>
<div id="boxes">
<div class="box-gutter"></div>
<div class="box-sizer"></div>
<?php while( have_rows('box_repeater') ): the_row();
$image_id = get_sub_field('link_image');
$image_size = 'box-thumbnail';
$image_array = wp_get_attachment_image_src($image_id, $image_size);
$linkImage = $image_array[0]; ?>
<?php if(get_sub_field('box_type') == "box-link"): ?>
<div class="box">
<div class="link-box">
<img src="<?php echo $linkImage; ?>" alt="<?php echo $linkImage['alt']; ?>" />
<a class="caption-wrapper" href="http://www.google.com">
<span id="link-box-content" style="background:<?php the_sub_field('link_background_colour'); ?>">
<h6 style="color:<?php the_sub_field('link_title_colour'); ?>"><?php the_sub_field('link_title'); ?></h6>
<h4 style="color:<?php the_sub_field('link_text_colour'); ?>"><?php the_sub_field('link_text'); ?></h4>
<p style="color:<?php the_sub_field('link_text_colour'); ?>" href="<?php the_sub_field('link_url'); ?>"><?php the_sub_field('link_url_text'); ?> ></p>
</span>
</a>
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-quote"): ?>
<div class="box">
<div class="quote-box">
<div class="quotation-mark"></div>
<h4><?php the_sub_field('quote'); ?></h2>
<p><?php the_sub_field('quote_source'); ?></p>
<?php the_sub_field('quote_link_text'); ?> >
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-twitter"): ?>
<div class="box">
<div class="twitter">
<a class="twitter-timeline" href="<?php the_sub_field('twitter_url'); ?>" data-widget-id="<?php the_sub_field('twitter_widget_id'); ?>" data-chrome="noheader noscrollbar nofooter noborders transparent" data-tweet-limit="<?php the_sub_field('number_of_tweets'); ?>"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<a class="twitter-badge" href="<?php the_sub_field('twitter_url'); ?>"></a>
<div class="twitter-bottom">See more ></div>
</div>
</div>
<?php endif;
endwhile;?>
</div>
</div>
</div>
<?php
/* Get the buffered content into a var */
$sc = ob_get_contents();
ob_end_clean();
return $sc;
}
add_shortcode('boxes', 'boxes_shortcode');
Can anyone help solve this mystery? Many thanks.
You have two extra closing <div>'s in your code.
Try this:
function boxes_shortcode($atts, $content = null) {
ob_start(); ?>
<div id="boxes">
<div class="box-gutter"></div>
<div class="box-sizer"></div>
<?php while( have_rows('box_repeater') ): the_row();
$image_id = get_sub_field('link_image');
$image_size = 'box-thumbnail';
$image_array = wp_get_attachment_image_src($image_id, $image_size);
$linkImage = $image_array[0]; ?>
<?php if(get_sub_field('box_type') == "box-link"): ?>
<div class="box">
<div class="link-box">
<img src="<?php echo $linkImage; ?>" alt="<?php echo $linkImage['alt']; ?>" />
<a class="caption-wrapper" href="http://www.google.com">
<span id="link-box-content" style="background:<?php the_sub_field('link_background_colour'); ?>">
<h6 style="color:<?php the_sub_field('link_title_colour'); ?>"><?php the_sub_field('link_title'); ?></h6>
<h4 style="color:<?php the_sub_field('link_text_colour'); ?>"><?php the_sub_field('link_text'); ?></h4>
<p style="color:<?php the_sub_field('link_text_colour'); ?>" href="<?php the_sub_field('link_url'); ?>"><?php the_sub_field('link_url_text'); ?> ></p>
</span>
</a>
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-quote"): ?>
<div class="box">
<div class="quote-box">
<div class="quotation-mark"></div>
<h4><?php the_sub_field('quote'); ?></h2>
<p><?php the_sub_field('quote_source'); ?></p>
<?php the_sub_field('quote_link_text'); ?> >
</div>
</div>
<?php endif;
if(get_sub_field('box_type') == "box-twitter"): ?>
<div class="box">
<div class="twitter">
<a class="twitter-timeline" href="<?php the_sub_field('twitter_url'); ?>" data-widget-id="<?php the_sub_field('twitter_widget_id'); ?>" data-chrome="noheader noscrollbar nofooter noborders transparent" data-tweet-limit="<?php the_sub_field('number_of_tweets'); ?>"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<a class="twitter-badge" href="<?php the_sub_field('twitter_url'); ?>"></a>
<div class="twitter-bottom">See more ></div>
</div>
</div>
<?php endif;
endwhile;?>
</div>
<!--/div>
</div-->
<?php
/* Get the buffered content into a var */
$sc = ob_get_contents();
ob_end_clean();
return $sc;
}
add_shortcode('boxes', 'boxes_shortcode');

2 columns in homepage wordpress

I modifying a wordpress template to be left with two columns on the main page with the following structure:
But the first 4 are of a category and the last 4 of another
The index code is:
http://pastebin.com/dMC0saBN
The page is (Columns are made, but all they do is repeat the post. They haven't order or filter)
crossfitlascondes.cl
The solution I occurred was to create two loops on the page and separated by , one to right column and one to left column. And so I can handle the code for each loop independently without interfering with the other column.
The code of index is:
<?php get_header();?>
<div id="contentslide">
<?php
include(TEMPLATEPATH . '/slide.php');
?>
</div>
<?php
get_sidebar();
?>
<div id="content">
<div class="clear">
</div>
<div id="contentleft">
<div id="noticias">Noticias</div>
<?php if ( is_home() ) { query_posts($query_string . '&cat=-27'); } ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="postleft" id="post-<?php
the_ID();
?>">
<div class="title">
<h2><a href="<?php
the_permalink();
?>" rel="bookmark" title="Permanent Link to <?php
the_title();
?>"><?php
the_title();
?></a></h2>
</div>
<div class="postmeta">
<span class="author">Posted by <?php
the_author();
?> </span> <span class="clock"> <?php
the_time('M - j - Y');
?></span> <span class="comm"><?php
comments_popup_link('0 Comment', '1 Comment', '% Comments');
?></span>
</div>
<div class="entry">
<?php
if (has_post_thumbnail()) {
?>
<a href="<?php
the_permalink();
?>"><img class="postimgleft" src="<?php
bloginfo('stylesheet_directory');
?>/timthumb.php?src=<?php
get_image_url();
?>&h=150&w=200&zc=1" alt=""/></a>
<?php
} else {
}
?>
<?php
wpe_excerpt('wpe_excerptlength_index', '');
?>
<div class="clear">
</div>
</div>
</div>
<?php
endwhile;
?>
<?php
endif;
?>
<?php
wp_reset_query();
?>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
</div>
<div id="contentright">
<div id="wod">WOD Diario</div>
<?php if ( is_home() ) { query_posts($query_string . '&cat=27&'); } ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="postright" id="post-<?php
the_ID();
?>">
<div class="title">
<h2><a href="<?php
the_permalink();
?>" rel="bookmark" title="Permanent Link to <?php
the_title();
?>"><?php
the_title();
?></a></h2>
</div>
<div class="postmeta">
<span class="author">Posted by <?php
the_author();
?> </span> <span class="clock"> <?php
the_time('M - j - Y');
?></span> <span class="comm"><?php
comments_popup_link('0 Comment', '1 Comment', '% Comments');
?></span>
</div>
<div class="entry">
<?php
if (has_post_thumbnail()) {
?>
<a href="<?php
the_permalink();
?>"><img class="postimgright" src="<?php
bloginfo('stylesheet_directory');
?>/timthumb.php?src=<?php
get_image_url();
?>&h=150&w=200&zc=1" alt=""/></a>
<?php
} else {
}
?>
<?php
wpe_excerpt('wpe_excerptlength_index', '');
?>
<div class="clear">
</div>
</div>
</div>
<?php
endwhile;
?>
<div class="clear"></div>
<?php
else:
?>
<h1 class="title">Not Found</h1>
<p>Sorry, but you are looking for something that isn't here.</p>
<?php
endif;
?>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
<?php
wp_reset_query();
?>
</div>
</div>
<?php
get_footer();
?>
and the code CSS(summarized) is
#content {
float:left;
width: 665px;
height:100%;
padding:10px 0px 0px 0px;
margin:23px 0px 0px 15px;
display:inline;
overflow:hidden;
}
#contentleft {
float:left;
width: 50%;
height:100%;
display:inline;
overflow:hidden;
}
#contentright {
float:left;
width: 44%;
margin-left: 23px;
height:100%;
display:inline;
overflow:hidden;
}
#contentslide {
float:left;
width: 665px;
height:100%;
padding:10px 0px 0px 0px;
margin:35px 0px 0px 15px;
display:inline;
overflow:hidden;
}

Categories