I've seen this article but it's not exactly relevant to what I'm trying to do. I have a simple blog loop in which each blog has an <div class="exerpt">for the preview of the blog text. All of my posts have a border-bottom and I'm simply trying to get rid of the border-bottom, as well as make other adjustments for the last-child. However every element is being styled, not just the last one. Please note I'm using the mighty html5blank
index.php
<div class="page-section" style="padding-top:150px;">
<div class="wrapper">
<?php get_template_part('loop'); ?>
<?php get_template_part('pagination'); ?>
</div>
</div>
loop.php
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="journal-title">
<?php the_title(); ?>
</h2>
<span class="date"><?php the_time('F j, Y'); ?> </span>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(); // Declare pixel size you need inside the array ?>
</a>
<?php endif; ?>
<!-- /post thumbnail -->
<!-- post title -->
<!-- /post title -->
<div class="exerpt">
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
</div>
</article>
.exerpt {
margin-bottom:80px;
border-bottom:1px solid #999;
padding:40px 0px 80px 0px;
}
.exerpt:last-child {
border:none;
margin-bottom: 60px;
}
Thanks!
You can add a separate class for the last item in the loop by doing something like this:
First add this before the loop starts:
<?php $post_counter = 0; ?>
Add this within the loop:
<?php $post_counter++; ?>
Then modify your excerpt code:
<div class="exerpt <?php if( $post_counter == count( $posts ) ) echo 'last-post'?>">
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
</div>
CSS:
.last-post {
border:none;
margin-bottom: 60px;
}
Related
I want to move left-sidebar which contains sticky top to below because it below to main header while down scrolling.
However, I cant add margin top to sticky-top under col-sm-1.
<style>
.col-sm-1 .sticky-top { margin-top: 50px}
</style>
50px is not important.The lenght should be enough to move the div to below header.
the page's codes:
<?php get_header(); ?>
<div class="container-fluid">
<!-- Control the column width, and how they should appear on different devices -->
<div class="row">
<div class="col-sm-10" >50%
<main role="main">
<!-- section -->
<section>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>
<!-- <a href="<?php //the_permalink(); ?>" title="<?php //the_title(); ?>"> -->
<?php the_post_thumbnail(); // Fullsize image for the single post ?>
</a>
<?php endif; ?>
<!-- /post thumbnail -->
<!-- post title -->
<h1>
<!-- <?php //the_title(); ?>-->
</h1>
<!-- /post title -->
<div class="row">
<div class="col-sm-1 " >50%
<?php global $post; ?>
<style>
.logo-img2{
border: 1px solid #d0d0ff;padding:20px; margin-top: 0px; margin-bottom: 0px;
}
</style>
<style>
.col-sm-1 .sticky-top { margin-top: 50px}
</style>
<div class="sticky-top ">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo get_permalink($post->ID);?>">
<div>
<img src="<?php echo get_template_directory_uri(); ?>/img/icons/facebook.png" alt="Logo" class="logo-img2"">
</div>
</a>
<a href="https://twitter.com/share?url=<?php echo get_permalink($post->ID);?>">
<div>
<img src="<?php echo get_template_directory_uri(); ?>/img/icons/twitter.png" alt="Logo" class="logo-img2"">
</div>
</a>
<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?>">
<div>
<img src="<?php echo get_template_directory_uri(); ?>/img/icons/pinterest.png" alt="Logo" class="logo-img2" >
</div>
</a>
<div class=" logo-img2" style="padding: 0px; text-align: center">
<ul class="list-inline">
<li class="list-inline-item">
Tooltip
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-11" >
<!-- post details -->
<span class="date"><?php the_time('F j, Y'); ?> <?php the_time('g:i a'); ?></span>
<span class="author"><?php _e( 'Published by', 'html5blank' ); ?> <?php the_author_posts_link(); ?></span>
<span class="comments"><?php if (comments_open( get_the_ID() ) ) comments_popup_link( __( 'Leave your thoughts', 'html5blank' ), __( '1 Comment', 'html5blank' ), __( '% Comments', 'html5blank' )); ?></span>
<!-- /post details -->
<?php the_content(); // Dynamic Content ?>
<?php the_tags( __( 'Tags: ', 'html5blank' ), ', ', '<br>'); // Separated by commas with a line break at the end ?>
<p><?php _e( 'Categorised in: ', 'html5blank' ); the_category(', '); // Separated by commas ?></p>
<p><?php _e( 'This post was written by ', 'html5blank' ); the_author(); ?></p>
<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
<?php comments_template(); ?>
</div>
</article>
<!-- /article -->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h1><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h1>
</article>
<!-- /article -->
<?php endif; ?>
</section>
<!-- /section -->
</main>
</div>
<div class="col-md-2" style="background-color:orange;height: 100%; width: 100%;">50%
<?php get_sidebar(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
There are some undeleted lines which is showed with <!-- so sorry.
The link : http://www.themeforest-deneme2.deniz-tasarim.site/2020/01/10/yazi-9/
Welcome to SO!
As you have position sticky so you need top value to move it like in your case set top: 60px rather then margin
.col-sm-1 .sticky-top {
/* margin-top: 50px; */
top: 60px;
}
The main difference between static or relative and absolute or fixed
was the space they take up in the flow of the DOM. Positions static &
relative keep their natural space in the flow of the document, while
the absolute & fixed don’t — their space is removed and they have a
floating behavior.
Reference for more understanding
Also its bad to use default frame-work classes to target any class/ make it selector
I have Genesis framework, And i have problem when set custom page as front page,
when set as home page, All post not show.
But when visit it as page i see all post.
where is problem ??
<div class="content-sidebar-wrap">
<main class="content" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/Blog">
<div id="content_box">
<?php
$i=0;
wp_reset_query();
query_posts('posts_per_page=10&post_type=post');
if(have_posts() ) :
while(have_posts()) : the_post();
?>
<article class="latestPost excerpt <? if($i%2==0){?> first <? } ?>" itemscope="" itemtype="http://schema.org/BlogPosting">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" id="featured-thumbnail">
<div class="featured-thumbnail">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail(array('370','297'));
}
?>
</div>
</a>
<header>
<h2 class="title front-view-title" itemprop="headline">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?>
</a>
</h2>
</header>
</article>
<?php
$i++;
endwhile;endif;
wp_reset_query();
?>
</div>
<?php add_action( 'genesis_after_content', 'genesis_get_sidebar' ); ?>
</main>
</div>
If your using a custom page, on edit page admin, there's a template selection and select for blog template, or you may use the custom template for custom blog content.
I think there is a if statement before the looping like is_front_page() or is_home(). If not, try the below code.
Example of custom page template is
/* Template Name: Custom page template */
add_action( 'genesis_meta', 'custom_page_template_function' );
function custom_page_template_function(){
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'custom_do_loop' );
}
function custom_do_loop(){
// content or custom query post
}
genesis();
First I'm going to explain the problem. I have a wordpress website with a few pages. One of the pages is the page that shows the summary of all the articles.
This is all working fine. What I want to archieve is the following:
Article 1 should be aligned to the left of the page, Article 2 should be aligned to the right and so on. (LEFT - RIGHT - LEFT - RIGHT - LEFT - ... )
I have no idea how to start. I have done some research and maybe wp_count_posts() is going to help me but I can't fix it.
Single.php (template for 1 post)
get_header(); ?>
<section class="news-area">
<div class="wrapper" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php
$count = count_posts( $type, $perm );
echo $count;
?>
<?php get_template_part( 'content', 'single' ); ?>
<?php group_joosen_post_nav(); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
?>
<?php endwhile; // end of the loop. ?>
</div><!--END wrapper-->
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
content.php ("template" for all the posts)
<article class="teasers" id="post-<?php the_ID(); ?>">
<div class="datum">
<div class="day">
<?php the_time('d') ?>
</div>
<div class="month">
/<?php the_time('m') ?>
</div>
<div class="year">
<?php the_time('Y') ?>
</div>
</div>
<div class="teaserscontent">
<h1><?php the_title(); ?></h1>
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<?php the_excerpt(); ?>
<?php else : ?>
<?php the_content( __( 'Lees meer', 'transport_joosen' ) ); ?>
<?php endif; ?>
</div>
</article><!-- #post-<?php the_ID(); ?> -->
You may be able to do this simply with CSS. Assuming the HTML has all article elements as siblings:
http://jsfiddle.net/isherwood/53rh3/
article {
width: 47%;
padding: 1%;
margin: 1%;
box-sizing: border-box;
display: inline-block;
vertical-align: top;
}
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.
I have this code in my header.php :
<div id="logo">
<?php if( get_option('of_logo') != '') { ?>
<a class="image" href="<?php echo get_option('home'); ?>/" title="Home">
<img src="<?php echo get_option('of_logo'); ?>" />
</a>
<?php } else { ?>
<h1 class="front-page-logo"><?php bloginfo('name'); ?></h1>
<h2><?php bloginfo('description'); ?></h2>
<?php } ?>
</div>
All works great! basically it says if the user uploads a logo image in the theme options panel, then show that image, else, show some text.
Now I need to replace this:
<?php } else { ?>
<h1 class="front-page-logo"><?php bloginfo('name'); ?></h1>
<h2><?php bloginfo('description'); ?></h2>
<?php } ?>
with display a image based on the style.css the user choose. And my problem here is if I go to each css file and declare a diferent image, then if the user uploads a image also, both images show on page.
So how can I do that?
thanks
Use a an id or class on your default logo and declare the image urls in the various css files using background-image:
<?php } else { ?>
<div id="default-logo"></div>
<?php } ?>
In the css files:
#default-logo {
background-image: url(".../1.jpg");
width: 80px;
height: 80px; /* the dimensions of your logo */
}