Change class of the last instance of an item within a loop with WordPress/ACF - php

I want to insert an arrow image between each div with the class product-icon in a WordPress loop using the ::after CSS pseudo-element. Right now the arrow shows up after every product-icon div the loop populates, but I want it to be hidden after the last one (and the number of divs displayed changes depending which page you're on). I'm guessing I'll need to change the class of the last div in the loop, but I'm not sure how to do that. Here's an HTML version so you can see what it should look like:
<section id="case-study-product-overview" class="horizontal">
<div class="max-container">
<div id="product-map-container">
<div>
<div class="product-icon"><img src="https://cdn4.iconfinder.com/data/icons/basic-for-user-interface-vol-1/24/add-_plus-_create_-square-_Add_Button-512.png"><p class="icon-subtitle">Icon 1</p></div>
<div class="product-card">
<h3 class="product-overview-title green-text">Title 1</h3>
<img class="product-image" src="https://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png">
<p class="blurb">Lorem ipsum dummy paragraph text.</p>
</div>
</div>
<div>
<div class="product-icon"><img src="https://cdn4.iconfinder.com/data/icons/basic-for-user-interface-vol-1/24/add-_plus-_create_-square-_Add_Button-512.png"><p class="icon-subtitle">Icon 2</p></div>
<div class="product-card">
<h3 class="product-overview-title green-text">Title 2</h3>
<img class="product-image" src="https://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png">
<p class="blurb">Lorem ipsum dummy paragraph text.</p>
</div>
</div>
<div>
<div class="product-icon"><img src="https://cdn4.iconfinder.com/data/icons/basic-for-user-interface-vol-1/24/add-_plus-_create_-square-_Add_Button-512.png"><p class="icon-subtitle">Icon 3</p></div>
<div class="product-card">
<h3 class="product-overview-title green-text">Title 3</h3>
<img class="product-image" src="https://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png">
<p class="blurb">Lorem ipsum dummy paragraph text.</p>
</div>
</div>
</div>
</div>
</section>
here's the PHP I am ACTUALLY working with:
<section id="case-study-product-overview" class="horizontal">
<div class="max-container">
<h2 class="cs-heading eaton-blue-text">Product Overview</h2>
<div id="product-map-container">
<?php if ( have_rows('product_overview_map') ): ?>
<?php while( have_rows('product_overview_map') ): the_row(); ?>
<div>
<!-- ** This line is what the arrow should come after, except the last one** -->
<div class="product-icon"><img src="<?php echo get_sub_field('product_overview_icon'); ?>"/>
</div>
<!-- -->
<p class="icon-subtitle"><?php echo get_sub_field('product_overview_icon_label'); ?></p>
<div class="product-card">
<h3 class="product-overview-title eaton-blue-text"><?php echo get_sub_field('product_title'); ?></h3>
<img class="product-image" src="<?php echo get_sub_field('product_image'); ?>" />
<p class="blurb"><?php echo get_sub_field('product_description'); ?></p>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</section>
and the CSS:
#case-study-product-overview .ecosystem-diagram {
min-height:650px;
margin-top:3%;
}
#case-study-product-overview .ecosystem-item {
position:absolute;
width:250px;
align-items:center;
margin-left:-125px;
margin-top:-100px;
}
#case-study-product-overview .image {
width:300px;
height:300px;
display:flex;
align-items:flex-end;
}
#case-study-product-overview .image img {
max-height:250px;
max-width:245px;
}
.product-icon::after {
content: url(http://wordpress-dev.tcc.etn.com/wordpress/iot/wp-content/uploads/sites/11/2019/07/arrows.png);
position: absolute;
top: 25px;
margin:0 32px;
}
.last-product-icon::after {
content:'';
}
.product-icon > img {
width: 50px;
height: 50px;
}
#product-map-container {
display: flex;
margin: 50px 0;
justify-content: center;
position: relative;
}
#product-map-container > div {
margin: 10px;
text-align: center;
}
.product-card {
box-shadow: 1px 1px 6px 1px #999;
max-width: 240px;
min-height: 475px;
padding: 10px;
}
.product-image {
width: 200px;
margin:auto;
}
Any help would be greatly appreciated. Thanks!

Related

How To Change Header Photo Whene Slide

i use swiper slider to make a profile slide the javascript is standar like in this github
https://github.com/nolimits4web/Swiper/blob/master/demos/390-autoheight.html
this the picture from my page
i use like this for the header photo
<div class="row">
<div class="col-12 p-0">
<img class="kol1">
</div>
</div>
and this is for the text-box
<!--text-->
<div class="col-12 bg-text-kol">
<div class="swiper-container swiper2" >
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="text-left">
</br>
<h2 class="h5 mt-3"><?php echo $this->lang->line('kol_15_name'); ?></h2>
<?php echo '#'.$this->lang->line('kol_15_ig'); ?>
<p class="mark-bold"><?php echo $this->lang->line('kol_15_title'); ?></p>
<p class="mt-3"><?php echo $this->lang->line('kol_15_text'); ?></p>
</br>
</div>
</div>
</div>
<!-- Add Pagination-->
<div class="swiper-pagination"></div>
</div>
</div>
The slider text box is running well
my question is how do every time I do a slide photo header change every time I do a slide?
Here is a sample how you could integrate the image in your slider. The .text-left is positioned absolute inside the .testamonial container above all other content inside of it.
HTML Code:
<div class="swiper-slide">
<div class="testamonial">
<div class="banner">
Get your free Engrave
</div>
<div class="photo">
<img src="https://upload.wikimedia.org/wikipedia/en/8/88/MagooAndDog.jpg"/></div>
<div class="text-left">
<h2 class="h5 mt-3">Mr. Triples</h2>
#mr_triples
<p class="mark-bold">Content User</p>
<p class="mt-3">Not that much here.</p>
</div>
</div>
</div>
CSS Code:
.photo {
width: 300px;
height: 300px;
max-width: 300px;
overflow: hidden;
}
.banner {
background-color: orange;
padding: 5px;
}
.text-left {
text-align: left;
position: absolute;
width: 200px;
border-radius: 10px 10px 0px 0px;
background-color: rgba(255,255,255,0.8);
bottom: 0;
left: 30px;
padding: 10px;
padding-top: 20px;
min-height: 100px;
}
Here is a codepen to show you how your desired effect can be achieved.

how can I get 3 data in cycle with jquery

I have a website which is using the CodeIgniter framework. In my one page I should get some data and list them. and I don't want to use the scrollbar on this page.
how can I get 3 data in cycle with jquery?
This code is getting just 1 data in cycle but I want to get 3 data in the cycle.
<ul class="list">
<?php foreach ($a_list as $hd) { ?>
<div id="content-1">
<a href="single.html">
<li>
<section class="list-left" style="border:0px solid red; width:30%; height:90px;">
<section class="list" style="border-bottom:1px solid red; width:100%; margin-top: 0; text-align: center">
<h6 class="title" >Hasta</h6>
</section>
<p class="adprice" style="color:black; text-align: center; font-size: -5;"><?= $hd->h_adi ?> <?= $hd->h_soyadi ?>
</section>
<section class="list-left"style="border:0px solid red; width:30%; height: 90px">
<section class="list" style="border-bottom:1px solid red; width:100%; margin-top: 0; text-align: center">
<h5 class="title" >Doktor</h5>
</section>
<p class="adprice" style="text-align: center">
<?= $hd->a_unvan ?>
<?= $hd->dr_adi ?>
<?= $hd->dr_sadi ?>
<br>
<p class=catpath style="text-align: center; margin-top: 0px !important; color:black">
<?=$hd->a_brans?>
Uzmanı
</p>
</p>
</section>
<section class="list-left" style="border:0px solid red; width:30%;height: 90px">
<section class="list" style="border-bottom:1px solid red; width:100%; margin-top: 0; text-align: center">
<h5 class="title" >Durum</h5>
</section>
<p class="adprice" style="color:blue;text-align: center"><?=$hd->h_durum?></p>
</section>
<div class="clearfix"></div>
</li>
</a>
</div>
<?php } ?>
<script src='<?=base_url()?>/assets/js/jquery.min.js'></script>
<script>
var divs = $('div[id^="content-"]').hide(),
i = 0;
(function cycle() {
divs.eq(i).fadeIn(400)
.delay(1000)
.fadeOut(400, cycle);
i = ++i % divs.length;
})();
</script>
<a href="single.html">
</a>
</ul>
zxcf

How can I have two different styles in the same page

I have inside the loop two DIV and I need put a style to one and another to the other DIV.
I do not know if I can do it with PHP, JS or CSS. This is my code:
-- the styles (this styles are in the same page, because I have a general style that I include) --
<?php
$style_1 = '<style>
.content .postcontent-0 .layout-item-0 { margin-bottom: 7px; }
.content .postcontent-0 .layout-item-1 { border-spacing: 10px 0px; border-collapse: separate; }
.content .postcontent-0 .layout-item-2 { border-top-style:solid; background: #ffffff; }
</style>';
$style_2 = '<style>
.content .postcontent-0 .layout-item-0 { color: #083752; background: ; border-collapse: separate; }
.content .postcontent-0 .layout-item-1 { color: #083752; }
.content .postcontent-0 .layout-item-2 { border-style:Double; border-radius: 15px; }
.content .postcontent-0 .layout-item-3 { padding-right: 10px;padding-left: 10px; }
</style>';
?>
-- the view
<?php for ($i = 0; $i < $contador; $i++) { ?>
<!--Here begin the STYLE_1-->
<div class="content-layout-wrapper layout-item-0">
<div class="content-layout layout-item-1">
<div class="content-layout-row">
<div class="layout-cell layout-item-2">
<p> Text #1 </p>
</div>
</div>
</div>
</div>
<!--Here END the STYLE_1-->
<!--Here begin the STYLE_2-->
<div class="postcontent postcontent-0 clearfix">
<div class="content-layout-wrapper layout-item-0">
<div class="content-layout-row">
<div class="content-layout layout-item-1">
Text #2
</div>
<div class="layout-cell layout-item-2" >
<p>
Text #3
</p>
</div>
</div>
</div>
<div class="content-layout">
<div class="content-layout-row">
<div class="content-layout layout-item-3">
<p>Text # 4</p>
</div>
</div>
</div>
</div>
<!--Here END the STYLE_2-->
<?php } // for i ?>
You can use different class name for two separate div but if you want to use this without change the existing class name then use inline css.Try this code:
<?php for ($i = 0; $i < $contador; $i++) { ?>
<!--Here begin the STYLE_1-->
<div class="content-layout-wrapper layout-item-0" style="margin-bottom: 7px;">
<div class="content-layout layout-item-1" style=" border-spacing: 10px 0px; border-collapse: separate; ">
<div class="content-layout-row">
<div class="layout-cell layout-item-2" style="border-top-style:solid; background: #ffffff;">
<p> Text #1 </p>
</div>
</div>
</div>
</div>
<!--Here END the STYLE_1-->
<!--Here begin the STYLE_2-->
<div class="postcontent postcontent-0 clearfix">
<div class="content-layout-wrapper layout-item-0" style="color: #083752; background: ; border-collapse: separate;">
<div class="content-layout-row">
<div class="content-layout layout-item-1" style="color: #083752;">
Text #2
</div>
<div class="layout-cell layout-item-2" style"border-style:Double; border-radius: 15px;">
<p>
Text #3
</p>
</div>
</div>
</div>
<div class="content-layout">
<div class="content-layout-row">
<div class="content-layout layout-item-3" style="padding-right: 10px;padding-left: 10px;">
<p>Text # 4</p>
</div>
</div>
</div>
</div>
<!--Here END the STYLE_2-->
<?php } // for i ?>

How do I horizontally align images in WordPress once turned into a PHP loop?

I want to unpack the question so that it is clear and you will see the code below. I turned my HTML Bootstrap page into a WordPress dynamic site. The images are no longer under the img tag. So if you look below, I am not sure if I need to be tweaking the col-xl-2 class or creating a has_post_thumbnail selector in CSS. I need for my images to go from vertically aligned to horizontally aligned. If you look at the The col-centered keeps it centered, but I need it to be horizontally aligned. I have tried following the guidance in the WordPress Codex regarding styling the_post_thumbnail and it has not helped.
This is my index.php file:
<?php
// Advanced Custom Fields
// this is a bunch of variables with our fields to echo out in PHP
$images_feature_title = get_field('images_feature_title');
$images_feature_body = get_field('images_feature_body');
$indianapolis_feature_title = get_field('indianapolis_feature_title');
$indianapolis_feature_body = get_field('indianapolis_feature_body');
$social_media_image = get_field('social_media_image');
$social_media_title = get_field('social_media_title');
$social_media_feature_body = get_field('social_media_feature_body');
?>
<?php get_header(); ?>
<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<?php
$notun = new WP_Query(array(
'post_type' => 'bcarousel'
));
$indicator = -1;
while($notun->have_posts()) : $notun->the_post(); $indicator++ ?>
<li data-target="#myCarousel" data-slide-to="<?php echo $indicator; ?>"<?php if($indicator == 0) : ?> class="active" <?php endif; ?>></li>
<?php endwhile; ?>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
$carousel = new WP_Query(array(
'post_type' => 'bcarousel',
));
$korim = 0;
while($carousel ->have_posts()) : $carousel ->the_post(); $korim ++ ?>
<?php if($korim == 1) : ?>
<div class="item active">
<?php else : ?>
<div class="item">
<?php endif; ?>
<div class="carousel-image">
<?php the_post_thumbnail(); ?>
<div class="carousel-caption">
<h1><?php the_title(); ?></h1>
<h2><?php the_content(); ?></h2>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<!-- Left and right Carousel Arrows -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div><!-- /.carousel -->
<!-- Images Feature Section
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->
<!-- <div class="container marketing"> -->
<!-- Three columns of text below the carousel -->
<section class="row content-region-1 pt40 pb40">
<div class="container">
<?php $loop = new WP_Query(array('post_type' => 'images_feature','orderby' => 'post_id', 'order' => 'ASC')); ?>
<?php while($loop->have_posts()) : $loop->the_post(); ?>
<div class="col-xl-2 col-centered">
<?php
if (has_post_thumbnail()) {
the_post_thumbnail();
}
?>
<p><?php the_title(); ?> »</p>
<?php endwhile; ?>
</div><!-- /.col-lg-2 -->
</div>
</section><!-- /.row -->
<!-- Indianapolis Feature Section
================================================== -->
<section class="row" id="indy-glass">
<div class="container">
<div class="col-md-12">
<h2><?php echo $indianapolis_feature_title; ?></h2>
<hr />
<p class="lead"><?php echo $indianapolis_feature_body; ?></p>
</div>
<div class="col-md-12 text-center">
<p><a class="btn btn-danger" href="#" role="button">Learn More »</a></p>
</div>
</div>
</section>
<section class="row content-region-2 pt40 pb40" id="customer-testimonial">
<div class="container">
<div class="col-md-12">
<h1>What Our Customers Are Saying...</h1>
<p class="lead">We love Mirror Concepts! The team is professional and courteous and the new weightroom
mirrors look awesome!</p>
<cite>~ Jeff and Cindy Kivett</cite>
<p>Read More »</p>
</div>
</div>
</section>
<!-- Social Media Section
================================================== -->
<section class="row content-region-3 pt40 pb40" id="indy-glass">
<div class="container">
<div class="col-md-12 facebook-page">
<!-- If user uploaded an image -->
<?php if(!empty($social_media_image)) : ?>
<img src="<?php echo $social_media_image['url']; ?>" alt="<?php echo $social_media_image['alt']; ?>">
<?php endif; ?>
</div>
<h2><?php echo $social_media_title; ?></h2>
<hr />
<?php $loop = new WP_Query(array('post_type' => 'social_media_feature','orderby' => 'post_id', 'order' => 'ASC')); ?>
<?php while($loop->have_posts()) : $loop->the_post(); ?>
<div class="col-lg-2 col-centered">
<?php
if (has_post_thumbnail()) {
the_post_thumbnail();
}
?>
<?php endwhile; ?>
</div><!-- /.col-lg-2 -->
<p>See more on Facebook »</p>
</div>
</section>
<?php get_footer(); ?>
In the style.css file you will see some selectors commented out because after turning this into WordPress dynamic they seem to be ineffectual.
Style.css file:
/*
Theme Name: Mirror and Glass Theme
Author: Daniel Cortes
Author URI: http://dancortes.com
Description: Theme developed for MediaFuel
Version: 1.0
*/
/* GLOBAL STYLES
-------------------------------------------------- */
/* Padding below the footer and lighter body text */
body {
background: url('/wp-content/themes/mirror_glass/assets/img/tile.jpg') top left repeat;
}
h1,h2,h3,h4,h5,h6 {
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-weight: bold;
font-family: "Comic Sans MS", cursive, sans-serif;
text-align: center;
}
a {
color: #000000;
}
a#gallery {
color: white;
font-size: 24px;
}
/*Non-Bootstrap CSS*/
.content-region-1, .content-region-2, .content-region-3 {
/*text-align: center;*/
/*float: right;*/
}
#customer-testimonial {
background: #3e4249;
color: white;
}
#showroom {
text-align: center;
}
.btn-danger {
padding: 10px 20px;
margin-bottom: 10px;
font-size: 20px;
border-radius: 10px;
}
.btn-default {
border: none;
background-color: transparent;
font-size: 24px;
}
/*.col-centered {
display: inline-block;
float: none;
}*/
.container {
max-width: 1020px;
}
.navbar-default {
background-color: white;
margin-bottom: 0;
}
.header {
padding-bottom: 20px;
border-bottom: 1px solid #e5e5e5;
}
.header h3 {
margin-top: 40px;
margin-bottom: 10px;
line-height: 40px;
}
.carousel-image {
margin: 0 auto;
}
p {
margin-top: 4px;
}
a.link {
font-size: 20px;
}
a:hover {
text-decoration: none;
}
a.btn-default:hover {
text-decoration: none;
}
.fa {
font-size: 98px;
margin-top: 10px;
margin-bottom: -10px;
opacity: 0.1;
}
.facebook-page {
position: relative;
line-height: -0.8;
}
/*.col-xl-2 {
margin: auto;
text-align: center;
width: 100%;
display: block;
}*/
#indy-glass {
background: white;
}
.footer {
padding-top: 19px;
text-align: center;
color: #777;
border-top: 1px solid #e5e5e5;
}
.content-region-4 {
background: #000000;
color: #ffffff;
}
.side-widget {
margin-bottom: 40px;
}
.side-widget h3 {
border-left: 5px;
padding-left: 10px;
margin-bottom: 15px;
}
/*==== MEDIA QUERIES ====*/
#media screen and (max-width: 991px) {
.img-rounded {
margin: 12px;
}
}

Center float except last row

I need to center some floated divs inside a container. The code I'm using works but I need the last row of floated elements to be aligned to the left and not centered. It's a photo album and all the thumbnails are automatically generated by a gallery script.
This is what the code produces
This is what I need
I don't think this is possible with css alone, maybe some jquery or php...
CSS
#gallery {
background-color: #ffffff;
border: 1px solid #999999;
margin: 0 auto;
overflow: hidden;
position: relative;
text-align: center;
width: 750px;
}
.image {*display:inline;
background: #F7F9FD;
border: 1px solid #E7F0F5;
display: -moz-inline-stack;
display: inline-block;
line-height: 100%;
margin: 1em;
padding: 0;
text-align:left;vertical-align:top;
zoom:1;
}
.imagethumb a, .imagethumb a:hover {
border:0;
display: block;
margin: 5px;
}
.imagethumb {float: left;}
.clear {clear: both}
The PHP code
<div id="gallery">
<?php while (next_image(false, $firstPageImages)): ?>
<div class="image">
<div class="imagethumb">
<?php printImageThumb(getAnnotatedImageTitle()); ?>
</div>
</div>
<?php endwhile; ?>
</div>
Generated html
<div id="gallery">
<div id="images">
<div class="image">
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
</div>
<div class="image">
<div class="imagethumb"><img src="/zen/cache/p101-02_110_thumb.jpg" alt="p101-02" /></div>
</div>
<div class="image">
<div class="imagethumb"><img src="/zen/cache/p101-04_110_thumb.jpg" alt="p101-04" /></div>
</div>
[...]
</div>
Not sure what you are doing with all those nast hacks.. no jquery or php needed. just css.
This works fine for me. I did add widths and heights on the images because I didn't feel like actually getting an image. buts its all the same.
CSS
#gallery { background-color: #fff; border: 1px solid #999; margin: 0 auto; overflow: hidden; position: relative; text-align: center; width: 750px; }
.imagethumb a,
.imagethumb a:hover { border:0; display: block; margin: 5px; }
.imagethumb {float: left; margin:5px; background: #F7F9FD; border: 1px solid #E7F0F5; width:100px; height:200px;}
.clear {clear: both}
HTML Final Output
<div id="gallery">
<div id="images">
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
</div>
<div class="clear"></div>
</div>
You could just align left the whole thing with a left-padding and achieve the same result.
Or, you could align left everything and place it in another div container that is centered.

Categories