Irregular layout with bootstrap [duplicate] - php

This question already has answers here:
Bootstrap row with columns of different height
(3 answers)
Closed 1 year ago.
Unexpected space exists in loop.depend screen width, the space appear or hidden
Link to the web page in the image
<div class="container">
<div class="row">
if (have_posts()): while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<div class="col-xxs-12 col-xs-6 col-sm-6 col-md-3 ulockd-prl5">
<div class="ficon-box text-center hvr-shadow ulockd-mb20">
<div class="ficon">
<span class="<?php echo get_post_meta($post->ID, 'hekim-extension_ozellikler_icon-select', true);?> text-thm" title="<?php the_title(); ?>"></span>
</div>
<div class="fib-details">
<h4><?php the_title(); ?></h4>
<p><?php the_excerpt();//html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?> <?php _e( 'Read More...', 'hekim' )?></p>
<?php // html5wp_excerpt('html5wp_index');?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>

need add <div class="clearfix visible-xxs-block"></div> after all 4th col-xxs-12 elements.
solution:
<div class="row">
<?php
$xxs_block = 1;
if (have_posts()): while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<?php $xxs_block++; ?>
<div class="col-xxs-12 col-xs-6 col-sm-6 col-md-3 ulockd-prl5">
<div class="ficon-box text-center hvr-shadow ulockd-mb20">
<div class="ficon">
<span class="<?php echo get_post_meta($post->ID, 'hekim-extension_ozellikler_icon-select', true);?> text-thm" title="<?php the_title(); ?>"></span>
</div>
<div class="fib-details">
<h4><?php the_title(); ?></h4>
<p><?php the_excerpt();//html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?> <?php _e( 'Read More...', 'hekim' )?></p>
<?php // html5wp_excerpt('html5wp_index');?>
</div>
</div>
</div>
<?php if ($xxs_block == 5) { ?> <div class="clearfix visible-xxs-block"></div> <?php } ?>

Related

How to change the WordPress search results page (using Betheme and Ajax search lite)

I'm currently working on a website for a client and I want to change the search results page. I tried a lot of things but when I search for something on the website I get search results, but without a image or description. My client want the website to show a image and a description.
Here is my search.php code:
/**
* The search template file.
*
* #package Betheme
* #author Muffin group
* #link https://muffingroup.com
*/
get_header();
$translate['search-title'] = mfn_opts_get('translate') ? mfn_opts_get('translate-search-title','Ooops...') : __('Ooops...','betheme');
$translate['search-subtitle'] = mfn_opts_get('translate') ? mfn_opts_get('translate-search-subtitle','No results found for:') : __('No results found for:','betheme');
$translate['published'] = mfn_opts_get('translate') ? mfn_opts_get('translate-published','Published by') : __('Published by','betheme');
$translate['at'] = mfn_opts_get('translate') ? mfn_opts_get('translate-at','at') : __('at','betheme');
$translate['readmore'] = mfn_opts_get('translate') ? mfn_opts_get('translate-readmore','Read more') : __('Read more','betheme');
?>
<div id="Content">
<div class="content_wrapper clearfix">
<div class="sections_group">
<div class="section">
<div class="section_wrapper clearfix">
<?php if( have_posts() && trim( $_GET['s'] ) ): ?>
<div class="column one column_blog">
<div class="blog_wrapper isotope_wrapper">
<div class="posts_group classic">
<?php
while ( have_posts() ):
the_post();
?>
<div id="post-<?php the_ID(); ?>" <?php post_class( array('post-item', 'clearfix', 'no-img') ); ?>>
<div class="post-desc-wrapper">
<div class="post-desc">
<?php if( mfn_opts_get( 'blog-meta' ) ): ?>
<div class="post-meta clearfix">
<div class="author-date">
<span class="author"><span><?php echo esc_html($translate['published']); ?> </span><i class="icon-user"></i> <?php the_author_meta('display_name'); ?></span>
<span class="date"><span><?php echo esc_html($translate['at']); ?> </span><i class="icon-clock"></i> <?php echo esc_html(get_the_date()); ?></span>
</div>
</div>
<?php endif; ?>
<div class="post-title">
<h2><?php the_title(); ?></h2>
</div>
<div class="post-excerpt">
<?php the_excerpt(); ?>
</div>
<div class="post-footer">
<div class="post-links">
<i class="icon-doc-text"></i> <?php echo esc_html($translate['readmore']); ?>
</div>
</div>
</div>
</div>
</div>
<?php
endwhile;
?>
</div>
<?php
if(function_exists( 'mfn_pagination' )):
echo mfn_pagination();
else:
?>
<div class="nav-next"><?php next_posts_link(esc_html__('← Older Entries', 'betheme')) ?></div>
<div class="nav-previous"><?php previous_posts_link(esc_html__('Newer Entries →', 'betheme')) ?></div>
<?php
endif;
?>
</div>
</div>
<?php else: ?>
<div class="column one search-not-found">
<div class="snf-pic">
<i class="themecolor <?php echo esc_attr(mfn_opts_get('error404-icon', 'icon-traffic-cone')); ?>"></i>
</div>
<div class="snf-desc">
<h2><?php echo esc_html($translate['search-title']); ?></h2>
<h4><?php echo esc_html($translate['search-subtitle']) .' '. esc_html($_GET['s']); ?></h4>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php if( is_active_sidebar( 'mfn-search' ) ): ?>
<div class="sidebar four columns">
<div class="widget-area clearfix <?php echo esc_attr(mfn_opts_get('sidebar-lines')); ?>">
<?php dynamic_sidebar( 'mfn-search' ); ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php get_footer();
<?php $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); ?>
<div class="post-img">
<img src="<?php echo $featured_img_url; ?>"/>
</div>
use above code in while loop to show image by using post id.

Wordpress Pagination on custom Loop

I have some code below, and the pagination seems to be failing after the second page. I'm sure that I've done something wrong on one of the loops.
Can someone sanity check my code below for me?
<?php get_header();?>
<!-- Carousel -->
<div class="container fullwidth">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active" style="background:url(<?php echo esc_url( home_url( '/' ) ); ?>wp-content/uploads/2018/09/testphoto.jpg);">
<div class="container">
<div class="carousel-caption microstory">
<h1>Backstage Blog</h1>
</div>
</div>
</div><!-- End Item -->
</div><!-- End Carousel Inner -->
</div>
</div>
<!-- End Carousel -->
<!-- Posts -->
<div class="container paddingtop paddingbottom">
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// are we on page one?
if(1 == $paged) { ?>
<div class="row row-eq-height paddingbottom">
<?php $query = new WP_Query( 'post_type=post&order=DESC&orderby=date&posts_per_page=1' ); ?>
<?php if ( $query->have_posts() ) :?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col col-lg-6 col-md-6 col-sm-6 col-xs-12 postpaddingbottom">
<div class="col-lg-12 col-xs-12">
<div class="featuredimage"><?php the_post_thumbnail('full'); ?></div>
<div class="blog-column">
<div class="titledatemain">
<h4><?php the_title(); ?></h4>
<ul class="blog-detail">
<li><i class="fa fa-calendar"></i> <?php the_time('F jS, Y'); ?></li>
</ul>
<p><?php the_excerpt(); ?></p>
</div>
Read More
</div>
</div>
</div>
<?php endwhile;?>
<?php endif; ?>
<?php $query2 = new WP_Query( 'post_type=advert&order=DESC&orderby=date&posts_per_page=1' ); ?>
<?php if ( $query2->have_posts() ) :?>
<?php while ( $query2->have_posts() ) : $query2->the_post();
$advert_url = get_post_meta($post->ID, 'url', true);
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); ?>
<div class="col col-lg-6 col-md-6 col-sm-6 col-xs-12 postpaddingbottom">
<a href="<?php echo $advert_url ?>"><div class="col-lg-12 col-xs-12 advertbox" style="background:url(<?php echo $featured_img_url ?>);">
</div></a>
</div>
<?php endwhile; endif; ?>
</div>
<?php
$query = new WP_Query( 'post_type=post&order=DESC&orderby=date&posts_per_page=3&offset=1&paged='. $paged ); ?>
<?php if ( $query->have_posts() ) :?>
<div class="row row-eq-height paddingbottom">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col col-lg-4 col-md-4 col-sm-4 col-xs-12 postpaddingbottom">
<div class="col-lg-12 col-xs-12">
<div class="featuredimage blogimagesmall" style="background:url(<?php the_post_thumbnail_url('full'); ?>);"></div>
<div class="blog-colum">
<div class="titledate">
<h4><?php the_title(); ?></h4>
<ul class="blog-detail">
<li><i class="fa fa-calendar"></i> <?php the_time( 'F jS, Y' ); ?></li>
</ul>
</div>
</div>
</div>
</div>
<?php endwhile;?>
</div>
<?php endif; ?>
<?php } else { ?>
<?php
$query = new WP_Query( 'post_type=post&order=DESC&orderby=date&posts_per_page=12&offset=4&paged='. $paged ); ?>
<?php if ( $query->have_posts() ) :?>
<div class="row row-eq-height paddingbottom">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col col-lg-4 col-md-4 col-sm-4 col-xs-12 postpaddingbottom">
<div class="col-lg-12 col-xs-12">
<div class="featuredimage blogimagesmall" style="background:url(<?php the_post_thumbnail_url('full'); ?>);"></div>
<div class="blog-colum">
<div class="titledate">
<h4><?php the_title(); ?></h4>
<ul class="blog-detail">
<li><i class="fa fa-calendar"></i> <?php the_time( 'F jS, Y' ); ?></li>
</ul>
</div>
</div>
</div>
</div>
<?php endwhile;?>
</div>
<?php
wp_reset_postdata();
endif; ?>
<?php } ?>
<div class="row paddingbottom">
<div class="pagenav">
<div class="alignleft"><?php previous_posts_link('Newer Posts', $query- >max_num_pages) ?></div>
<div class="alignright"><?php next_posts_link('Older Posts', $query->max_num_pages) ?></div>
</div>
</div>
</div>
<!-- End Posts -->
<?php get_footer();?>
I'm sure that there is just a mistake in my loop. I have essentially got a different layout on the first page to the rest of the pages (as you will see).
It just seems that after page 2, when you go to the 3rd page, it just keeps displaying the 2nd page content.
Any help would be great.
Here is the updated code:
<?php /* Template Name: Blog Page */ ?>
<?php get_header();?>
<!-- Carousel -->
<div class="container fullwidth">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active" style="background:url(<?php echo esc_url( home_url( '/' ) ); ?>wp-content/uploads/2018/09/testphoto.jpg);">
<div class="container">
<div class="carousel-caption microstory">
<h1>Backstage Blog</h1>
</div>
</div>
</div><!-- End Item -->
</div><!-- End Carousel Inner -->
</div>
</div>
<!-- End Carousel -->
<!-- Posts -->
<div class="container paddingtop paddingbottom">
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// are we on page one?
$query = new WP_Query( 'post_type=post&order=DESC&orderby=date&posts_per_page=12&paged='. $paged );
if(1 == $paged) { ?>
<?php if ( $query->have_posts() ) { ?>
<div class="row row-eq-height paddingbottom">
<?php $temp_query2 = $wp_query2; ?>
<?php $query3 = new WP_Query( 'post_type=post&order=DESC&orderby=date&posts_per_page=1' ); ?>
<?php while ( $query3->have_posts() ) : $query3->the_post(); ?>
<div class="col col-lg-6 col-md-6 col-sm-6 col-xs-12 postpaddingbottom">
<div class="col-lg-12 col-xs-12">
<div class="featuredimage"><?php the_post_thumbnail('full'); ?></div>
<div class="blog-column">
<div class="titledatemain">
<h4><?php the_title(); ?></h4>
<ul class="blog-detail">
<li><i class="fa fa-calendar"></i> <?php the_time('F jS, Y'); ?></li>
</ul>
<p><?php the_excerpt(); ?></p>
</div>
Read More
</div>
</div>
</div>
<?php endwhile; ?>
<?php $wp_query2 = $temp_query2; ?>
<?php $temp_query = $wp_query; ?>
<?php $query2 = new WP_Query( 'post_type=advert&order=DESC&orderby=date&posts_per_page=1' ); ?>
<?php while ( $query2->have_posts() ) : $query2->the_post();
$advert_url = get_post_meta($post->ID, 'url', true);
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); ?>
<div class="col col-lg-6 col-md-6 col-sm-6 col-xs-12 postpaddingbottom">
<a href="<?php echo $advert_url ?>"><div class="col-lg-12 col-xs-12 advertbox" style="background:url(<?php echo $featured_img_url ?>);">
</div></a>
</div>
<?php endwhile; ?>
<?php $wp_query = $temp_query; ?>
</div>
<div class="row row-eq-height paddingbottom">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col col-lg-4 col-md-4 col-sm-4 col-xs-12 postpaddingbottom">
<div class="col-lg-12 col-xs-12">
<div class="featuredimage blogimagesmall" style="background:url(<?php the_post_thumbnail_url('full'); ?>);"></div>
<div class="blog-colum">
<div class="titledate">
<h4><?php the_title(); ?></h4>
<ul class="blog-detail">
<li><i class="fa fa-calendar"></i> <?php the_time( 'F jS, Y' ); ?></li>
</ul>
</div>
</div>
</div>
</div>
<?php endwhile;
rewind_posts();
}?>
</div>
<?php } else { ?>
<div class="row row-eq-height paddingbottom">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col col-lg-4 col-md-4 col-sm-4 col-xs-12 postpaddingbottom">
<div class="col-lg-12 col-xs-12">
<div class="featuredimage blogimagesmall" style="background:url(<?php the_post_thumbnail_url('full'); ?>);"></div>
<div class="blog-colum">
<div class="titledate">
<h4><?php the_title(); ?></h4>
<ul class="blog-detail">
<li><i class="fa fa-calendar"></i> <?php the_time( 'F jS, Y' ); ?></li>
</ul>
</div>
</div>
</div>
</div>
<?php endwhile;?>
</div>
<?php wp_reset_postdata(); ?>
<?php } ?>
<div class="row paddingbottom">
<div class="pagenav">
<div class="alignleft"><?php previous_posts_link('Newer Posts', $query->max_num_pages) ?></div>
<div class="alignright"><?php next_posts_link('Older Posts', $query->max_num_pages) ?></div>
</div>
</div>
</div>
<!-- End Posts -->
<?php get_footer();?>
You should see i'm now running one loop which is nice.. but I have put the first post in its own loop within a loop to show the first post. The issue i'm having now is that I want to on the main loop and only on the first page, have an offset of 1. But I can't work out how to do this just on the first page :(

Looping posts of a custom post type in diffrent columns

I have a custom post type "case_studies" i want posts from this, to arrange in a following way.
<div class="col-sm-3 nopadding">
IMAGE
</div>
<div class="col-sm-3 ">
TEXT
</div>
<div class="col-sm-3 nopadding">
IMAGE
</div>
<div class="col-sm-3 ">
TEXT
</div>
<!--
Column Ends
3rd & 4th posts
-->
<div class="item">
<div class="col-sm-6 nopadding">
IMAGE
</div>
<div class="col-sm-6">
TEXT
</div>
</div>
<div class="item">
<div class="col-sm-6 nopadding">
IMAGE
</div>
<div class="col-sm-6">
TEXT
</div>
</div>
<!--
Column Ends
-->
Then again first & second post type column after that again 4th & 5th post type column same loop goes on. note that each column ends after 2 posts & styles are diffrent. how can i achieve this
in short odd columns must have 2 posts which wrapped with col-sm-3, even columns also have 2 posts each one wrapper with col-sm-6.
Try this code.
<?php
$loop = new WP_Query( array( 'post_type' => 'case_studies') );
$Inc = 1;
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if($Inc==1){ ?>
<div class="col-sm-3 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-3 ">
<h2><?php echo get_the_title(); ?></h2>
</div>
<?php }else if($Inc==2){ ?>
<div class="col-sm-3 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-3 ">
<h2><?php echo get_the_title(); ?></h2>
</div>
<?php }else if($Inc==3){ ?>
<div class="item">
<div class="col-sm-6 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-6">
<h2><?php echo get_the_title(); ?></h2>
</div>
</div>
<?php }else if($Inc==4){ ?>
<div class="item">
<div class="col-sm-6 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-6">
<h2><?php echo get_the_title(); ?></h2>
</div>
</div>
<?php } ?>
<?php
if($Inc==4){
$Inc =1;
}
$Inc++;
endwhile;
endif;
wp_reset_postdata();
?>

Odd/even html in php loop not alternating properly

I've been searching through questions/answers on here, but can't seem to find something that works with my code.
Most of the solutions I've found cause the whole page to get a 500 error. They're generally just snippets of the odd/even php, and aren't working for me to easily integrate with the custom post type loop php I have. I'm probably just not putting it in the right place, but nothing seem to be working.
I'm not super great with php, but this is the one thing I've always had an issue getting to work.
Goal:
Odd posts have the headshot on the left, bio info on the right.
Even posts have the headshot on the right, bio info on the left.
Below is my code, which does load on the page (no 500 error), but doesn't output the alternating layout, just outputs the same layout as if I didn't have the odd/even code.
<?php // theloop
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $loop = new WP_Query( array( 'post_type' => 'team', 'posts_per_page' => -1, 'order' => 'ASC') ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if ($wp_query->current_post % 2 == 0): ?>
<div class="row team-member"> <!--ODD LAYOUT // HEADSHOT LEFT - BIO RIGHT-->
<div class="container">
<div class="row is-table-row">
<div class="col-sm-6 headshot" style="background-image:url(<?php the_field('bio_photo'); ?>);">
<div class="box">
</div>
</div>
<div class="col-sm-6 bio cream-bg">
<div class="box">
<?php if( get_field('additional_logo') ): ?>
<div class="additional-logo"><img src="<?php the_field('additional_logo'); ?>"></div>
<?php endif; ?>
<h2><?php the_field('name'); ?></h2>
<div class="bio-content"><?php the_field('bio'); ?></div>
<div class="contact-container">
<h4>Contact me!</h4>
<?php if( get_field('phone_number') ): ?>
<p><i class="fa fa-phone" aria-hidden="true"></i> <?php the_field('phone_number'); ?></p>
<?php endif; ?>
<p><i class="fa fa-envelope" aria-hidden="true"></i> <?php the_field('email'); ?></p>
</div>
</div>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="row team-member"> <!--EVEN LAYOUT // HEADSHOT RIGHT - BIO LEFT-->
<div class="container">
<div class="row is-table-row">
<div class="col-sm-6 bio cream-bg">
<div class="box">
<?php if( get_field('additional_logo') ): ?>
<div class="additional-logo"><img src="<?php the_field('additional_logo'); ?>"></div>
<?php endif; ?>
<h2><?php the_field('name'); ?></h2>
<div class="bio-content"><?php the_field('bio'); ?></div>
<div class="contact-container">
<h4>Contact me!</h4>
<?php if( get_field('phone_number') ): ?>
<p><i class="fa fa-phone" aria-hidden="true"></i> <?php the_field('phone_number'); ?></p>
<?php endif; ?>
<p><i class="fa fa-envelope" aria-hidden="true"></i> <?php the_field('email'); ?></p>
</div>
</div>
</div>
<div class="col-sm-6 headshot" style="background-image:url(<?php the_field('bio_photo'); ?>);">
<div class="box">
</div>
</div>
</div>
</div>
</div>
<?php endif ?>
<?php endwhile; wp_reset_query(); ?>
Is there anything I've done wrong here, or a better solution to this? I'm frustrated that this is theoretically a simple request that I just can't seem to make work properly. Any help is much appreciated!
OK, pro tip: programmers are lazy. We like the DRY principle. We don't like to duplicate code, nor do we like to maintain giant blocks of duplicated code.
So, below is a modified version of your loop that is somewhat simpler, with less duplication. I would encourage you to consider other ways to reduce duplication, for example, using CSS classes (floats, possibly) to alternate which is on the left or right, and only render one version of the HTML one time.
The specific problem is that you're not accessing the $current_post property of the correct query object. You should be using $loop->current_post instead of $wpdb->current_post. However, to be super clear / explicit, I would manually set a counter, and use that instead:
<?php // theloop
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $loop = new WP_Query( array( 'post_type' => 'team', 'posts_per_page' => -1, 'order' => 'ASC') ); ?>
<?php
// initialize the counter here
$post_count = 0;
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="row team-member">
<div class="container">
<div class="row is-table-row">
<?php
// move the if condition here to reduce / simplify code
// reference (and increment) the counter
if ($post_count++ % 2 == 0): ?>
<div class="col-sm-6 headshot" style="background-image:url(<?php the_field('bio_photo'); ?>);">
<div class="box">
</div>
</div>
<div class="col-sm-6 bio cream-bg">
<div class="box">
<?php if( get_field('additional_logo') ): ?>
<div class="additional-logo"><img src="<?php the_field('additional_logo'); ?>"></div>
<?php endif; ?>
<h2><?php the_field('name'); ?></h2>
<div class="bio-content"><?php the_field('bio'); ?></div>
<div class="contact-container">
<h4>Contact me!</h4>
<?php if( get_field('phone_number') ): ?>
<p><i class="fa fa-phone" aria-hidden="true"></i> <?php the_field('phone_number'); ?></p>
<?php endif; ?>
<p><i class="fa fa-envelope" aria-hidden="true"></i> <?php the_field('email'); ?></p>
</div>
</div>
</div>
<?php else: ?>
<div class="col-sm-6 bio cream-bg">
<div class="box">
<?php if( get_field('additional_logo') ): ?>
<div class="additional-logo"><img src="<?php the_field('additional_logo'); ?>"></div>
<?php endif; ?>
<h2><?php the_field('name'); ?></h2>
<div class="bio-content"><?php the_field('bio'); ?></div>
<div class="contact-container">
<h4>Contact me!</h4>
<?php if( get_field('phone_number') ): ?>
<p><i class="fa fa-phone" aria-hidden="true"></i> <?php the_field('phone_number'); ?></p>
<?php endif; ?>
<p><i class="fa fa-envelope" aria-hidden="true"></i> <?php the_field('email'); ?></p>
</div>
</div>
</div>
<div class="col-sm-6 headshot" style="background-image:url(<?php the_field('bio_photo'); ?>);">
<div class="box">
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>

wordpress loop – different html for every 2nd custom post

i am searching since a while for a solution to set my custom post loop like this:
first post> img left, content right // second post> content left, img right
this is my code so far:
<div class="container">
<?php $loop = new WP_Query( array( 'post_type' => 'profile', 'posts_per_page' => 10 ) ); ?>
<?php if (have_posts()) : while(have_posts()) : the_post(); $i++; if(($i % 2) == 0) : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(''); ?> role="article" itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
<div class="row centered wow fadeInUpBig" data-wow-duration="2s">
<div class="col col-4">
<?php the_post_thumbnail(600); ?>
</div>
<div class="col col-6">
<section class="entry-content cf" itemprop="articleBody">
<span class="bold function"><?php echo get_the_term_list( $post->ID, 'Funktion', '', ', ', '' ); ?></span>
<h2 class="entry-title single-title" itemprop="headline" rel="bookmark"><?php the_title(); ?></h2>
<?php the_content();?>
</section>
</div>
</div>
</article>
<?php else : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(''); ?> role="article" itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
<div class="row centered wow fadeInUpBig" data-wow-duration="2s">
<div class="col col-6">
<section class="entry-content cf" itemprop="articleBody">
<span class="bold function"><?php echo get_the_term_list( $post->ID, 'Funktion', '', ', ', '' ); ?></span>
<h2 class="entry-title single-title" itemprop="headline" rel="bookmark"><?php the_title(); ?></h2>
<?php the_content();?>
</section>
</div>
<div class="col col-4">
<?php the_post_thumbnail(600); ?>
</div>
</div>
</article>
<?php endif; endwhile; endif; ?>
</div>
I know, this question has been asked a couple of times, and i tried already this and this and i read this but nothing works for me. What am i doing wrong?
I imagine its only outputting one post, and that post is actually the post content attached to the page. The problem is how you are initialising your additional loop within the page. You are creating a new post object - but you are not assigning it to the if / while statements:
<?php if (have_posts()) : while(have_posts()) : the_post(); $i++; if(($i % 2) == 0) : ?>
should be:
<?php if ($loop->have_posts()) : while($loop->have_posts()) : $loop->the_post(); $i++; if(($i % 2) == 0) : ?>
Notice the addition of the $loop variable where you are setting your post object and arguments.
i got this code (not altering) working already:
<div class="container">
<?php $loop = new WP_Query( array( 'post_type' => 'profile', 'posts_per_page' => 10 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(''); ?> role="article" itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
<div class="row centered wow fadeInUpBig" data-wow-duration="2s">
<div class="col col-4">
<?php the_post_thumbnail(600); ?>
</div>
<div class="col col-6">
<section class="entry-content cf" itemprop="articleBody">
<span class="bold function"><?php echo get_the_term_list( $post->ID, 'Funktion', '', ', ', '' ); ?></span>
<h2 class="entry-title single-title" itemprop="headline" rel="bookmark"><?php the_title(); ?></h2>
<?php the_content();?>
</section>
</div><!--.end col-->
</div><!--.end row-->
</article>
<?php endwhile; wp_reset_query(); ?>
</div><!--.end container-->

Categories