I use ACF repeater in my wordpress website.
Each repeater display in a col-md-6.
I would like to display the last in a col-md-12.
<div class="container">
<?php if ( have_rows( 'salon' ) ) : ?>
<div class="row">
<?php while ( have_rows( 'salon' ) ) : the_row(); ?>
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h2 class="card-title">Card title</h2>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
Try this example with your code it's working for me.
<?php if( have_rows('services_repeater', $services) ): ?>
<?php $rowCount = count( get_field('services_repeater', $services) ); //GET THE COUNT ?>
<?php $i = 1; ?>
<?php while( have_rows('services_repeater', $services) ): the_row(); ?>
<?php // vars
$service = get_sub_field('service');
$description = get_sub_field('description');
?>
<span class="hint--bottom" data-hint="<?php echo $description; ?>"><?php echo $service; ?></span>
<?php if($i < $rowCount): ?>
<div id="separator"> / </div>
<?php endif; ?>
<?php $i++; ?>
<?php endwhile; ?>
<?php endif; ?>
Related
I want to display my Wordpress posts across two columns. At the moment, they run down one column. I'm also getting the categories repeating in the col-lg-2 div as I scroll down. Any tips? Thanks!
<div class="container">
<?php // Display blog posts on any page # https://m0n.co/l
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('posts_per_page=-1' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="row">
<div class="col-lg-2">
<?php the_category(', '); ?>
</div>
<div class="col-lg-5">
<?php the_post_thumbnail(); ?>
<p><?php the_title(); ?></p>
</div>
<div class="col-lg-5">
<h2><?php the_title(); ?></h2>
</div>
</div>
<?php endwhile; ?>
<?php if ($paged > 1) { ?>
<?php } else { ?>
<?php } ?>
<?php wp_reset_postdata(); ?>
</div>
I'm having problem with my Wordpress 4.7.8 localhost custom-theme webpage.
As hard as I try, I keep getting "Title" where content should be and the content at the place of the title
Here is an image
Here is how it looks in wordpress admin dashboard:
...and image the view in wordpress
any Ideas where I might be going wrong?
Try this code.
Search bar in duplicate (wordpress/php/bootstrap)
This code taken from your previous question.
this code for displaying title <?php the_title(); ?> and this code displaying content <?php the_content(); ?>. you can replace this code wherever you want.
<?php get_header(); ?>
<div class="row">
<div class="col-xs-12 col-sm-8">
<div class="row text-center no-margin">
<?php
$currentPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 3,'post_type'=>'post', 'paged' => $currentPage);
new WP_Query($args);
if( have_posts() ): $i = 0;
while( have_posts() ): the_post(); ?>
<?php
if($i==0): $column = 12; $class = '';
elseif($i > 0 && $i <= 2): $column = 6; $class = ' second-row-padding';
elseif($i > 2): $column = 4; $class = ' third-row-padding';
endif;
?>
<div class="col-xs-<?php echo $column; echo $class; ?> blog-item">
<?php if( has_post_thumbnail() ):
$urlImg = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
endif; ?>
<div class="blog-element" style="background-image: url(<?php echo $urlImg; ?>);">
<!--<?php the_title( sprintf('<h1 class="entry-title">', esc_url( get_permalink() ) ),'</h1>' ); ?> -->
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php the_content(); ?>
<small><?php the_category(' '); ?></small>
</div>
</div>
<?php $i++; endwhile; ?>
<div class="col-xs-6 text-left">
<?php next_posts_link('« Older Posts'); ?>
</div>
<div class="col-xs-6 text-right">
<?php previous_posts_link('Newer Posts »'); ?>
</div>
<?php endif;
wp_reset_query();
?>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<?php get_sidebar(); ?>
</div>
</div>
You might need to edit content-single.php file to change the post content order. Your post content is loading first before post title.
Check if ,
the_content() or get_the_content()
is showing before ,
get_the_title() or the_title()
I'm trying to create a two column element using ACF repeater fields. The only thing is I'm trying to alternate this so that the content in the two columns switches left/right depending on the row being even or odd.
The output will look something like:
This is how I looped:
<section id="projects" class="container specific-margin-1">
<!-- Repeater -->
<div class="row">
<?php $i=0 ; if(get_field( 'featured_projects')): ?>
<?php while(has_sub_field( 'featured_projects')): $i++; ?>
<div class="row">
<?php
/*
* Loop through post objects (assuming this is a multi-select field) ( setup postdata )
* Using this method, you can use all the normal WP functions as the $post object is temporarily initialized within the loop
* Read more: http://codex.wordpress.org/Template_Tags/get_posts#Reset_after_Postlists_with_offset
*/
$post_objects = get_field('featured_projects');
if($post_objects ): ?>
<ul>
<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<div class="repeater_row <?php if (($i % 2)==0 ): ?>col-lg-3 col-md-4 col-sm-6<?php else: ?>col-lg-9 col-md-8 col-sm-6<?php endif; ?>">
<?php if (($i % 2)==0 ): ?>
<li>
<h3><?php the_title(); ?></h3>
<h3><?php the_field('project_location'); ?></h3>
<br>
<span><?php the_field('project_area'); ?></span><br>
<span><?php the_field('project_scale'); ?></span><br>
<br>
<span style="color:#EE1601;">Explore this project <i class="fa fa-arrow-circle-right" aria-hidden="true"></i></span>
</li>
<?php else:
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<?php endif; ?>
</div>
<div class="repeater_row <?php if (($i % 2)==0 ): ?>col-lg-9 col-md-8 col-sm-6<?php else: ?>col-lg-3 col-md-4 col-sm-6<?php endif; ?>">
<?php if (($i % 2)==0 ): ?>
<?php // check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<?php else: ?>
<li>
<?php // check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<h3><?php the_title(); ?></h3>
<h3><?php the_field('project_location'); ?></h3>
<br>
<span><?php the_field('project_area'); ?></span><br>
<span><?php the_field('project_scale'); ?></span><br>
<br>
<span style="color:#EE1601;">Explore this project <i class="fa fa-arrow-circle-right" aria-hidden="true"></i></span>
</li>
<?php endif; ?>
</div>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif;?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<!-- Repeater -->
</section>
My Current Output looks like this:
This is the minimal logic for having alternate image and text row wise.
<div class="container">
<div class="row">
<?php
for ($i = 1; $i <= 10; $i++)
{
//even counter will have right image
if ($i % 2 == 0)
{
?>
<div class="col-md-12">
<div class="col-md-4">
Title Number: <?php echo $i; ?>
</div>
<div class="col-md-8">
<img src="" class="img-responsive"/>
</div>
</div>
<?php
}
//odd counter will have left image
else
{
?>
<div class="col-md-12">
<div class="col-md-8">
<img src="" class="img-responsive"/>
</div>
<div class="col-md-4">
Title Number: <?php echo $i; ?>
</div>
</div>
<?php
}
}
?>
</div>
</div>
Hope this will give you an idea.
I want to implement pagination on custom post type of a custom taxonomy.
but it is not showing the pagination links only shows on default posts but not working. When I click on next link it redirect me to the index page.
Any help.(New to Wordpress)
Code
<?php $term = get_queried_object();
$taxonomy = get_taxonomy($term->taxonomy);
?>
<div class="panel-heading"><h4><?php echo 'محصولات : '.$term->name;?></h4></div>
<div class="panel-body">
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array('post_type'=>'my_product', 'taxonomy'=>$taxonomy->name,
'posts_per_page'=> 1,
'term'=>$term->slug, 'paged'=>$paged);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()): $query->the_post(); ?>
<div class="thumbnail">
<?php if (has_post_thumbnail()) {
the_post_thumbnail('featured');
} ?>
<div class="caption caption-content">
<h3><?php the_title(); ?></h3>
<p class="text-muted">
<!-- <strong>نویسنده:</strong> <?php //the_author();?> -->
تاریخ: <?php the_date(); ?></p>
<p> <?php the_excerpt(); ?> </p>
<div>
<p class="price-box">
<i class="fa fa-circle"> </i>قیمت:
<?php if (the_field('price') == '') {
// echo "00.00";
} else {
the_field('price');
} ?>
</p>
</div>
</div>
<hr>
</div>
<?php endwhile;
}
else {
echo '<h3>هیچ موردی درین بخش یافت نشد.</h3>';
}
?>
<!-- pagination here -->
<p> <?php
if (function_exists("custom_pagination")):
custom_pagination($custom_query->max_num_pages,"",$paged);
endif;
?>
<?php wp_reset_postdata(); ?>
</p>
</div>
When displaying my repeater field onto the front-end it will display everything in that list apart from the very first item. I would like it to display everything in the repeater.
<?php if( have_rows('the_list') ): the_row(); ?>
<div class="row">
<?php while( have_rows('the_list') ): the_row(); ?>
<div class="col-md-8">
<h6><?php the_sub_field('name') ?></h6>
<p><?php the_sub_field('number') ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
You are running the_row(); twice. Removing this from after your if statement should fix your issue.
Here is an updated snippet:
<?php if( have_rows('the_list') ): ?>
<div class="row">
<?php while( have_rows('the_list') ): the_row(); ?>
<div class="col-md-8">
<h6><?php the_sub_field('name') ?></h6>
<p><?php the_sub_field('number') ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php global $post; ?>
<?php if( have_rows('the_list'), $post->ID ): ?>
<div class="row">
<?php while( have_rows('the_list'), $post->ID ): the_row(); ?>
<div class="col-md-8">
<h6><?php the_sub_field('name') ?></h6>
<p><?php the_sub_field('number') ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>