I have set up a query to query 80 posts per page on a day date basis but it doesn't load page 2 for me. It always says 404 error. I don't really know where I have gone wrong. This is the code.
<div class="mainvideoscon">
<div class="videosallcenter">
<?php
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
'post_type' => array('post','video', 'featured', 'spotlight'),
'paged' => $paged
);
$wp_query = new WP_Query($args);
if (have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();
if ($current_date != get_the_date('d-m-Y')) {
echo '<div class="datetitlecon"><header class="datetitleh"><span class="datetitlehb"><i class="fa fa-clock-o"></i> ' . get_the_date('l ') . '</span>';
echo '' . get_the_date('dS M Y') . '</header></div>';
$current_date = get_the_date('d-m-Y');
}
?>
<div class="mvideocontv">
<a href="<?php the_permalink() ?>"><div class="mvideocontvfi">
<div class="gopostitem">
<?php
$posttype = get_post_type(get_the_ID());
if ($posttype == "post") {
echo '<img src="/wp-content/themes/justlooktv/images/gonews.png">';
}
if ($posttype == "video") {
echo '<img src="/wp-content/themes/justlooktv/images/play.png">';
}
if ($posttype == "spotlight") {
echo '<img src="/wp-content/themes/justlooktv/images/play.png">';
}
if ($posttype == "featured") {
echo '<img src="/wp-content/themes/justlooktv/images/play.png">';
}
?>
</div>
<div class="featuredimgblg"><?php the_post_thumbnail( 'ftimg-home' ); ?></div>
<?php if ('in_stock' == get_field('show_youtube_video')) { ?>
<img src="https://i.ytimg.com/vi/<?php the_field('youtube_video_id'); ?>/mqdefault.jpg" >
<?php } ?>
</div></a>
<div class="mvideodesccontv">
<div class="ppw"></div>
<?php short_title('...', 58); ?>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="paginationcon">
<div class="paginationfocus">
<?php wp_pagenavi(); ?>
</div>
</div>
<?php endif; ?>
<?php wp_reset_query(); ?>
Thanks for the help in advance
Try Replacing your $arg variable with this one.
$args = array (
'post_type' => array('post','video', 'featured', 'spotlight'),,
'post_status' => 'publish',
'pagination' => true,
'posts_per_page' => '80',
);
Related
I need to insert a pagination to the post instead of the load more button and I don't know how how to do it. I require pagination of Next & Previous or numbers.
Here's our dev work, but I don't know where to start or where I should put this example.
<?php
/*
* Template Name: Blog
* description: >-
Page template without sidebar
*/
get_header(); ?>
<body class=" pageHeader--gray">
<div class="wrapper">
<div class="content">
<div class="pageHeader">
<div class="container animate">
<h1 class="pageHeader__title"><?php the_field('title'); ?>
</h1>
</div>
<div class="pageHeader__background">
<svg xmlns="http://www.w3.org/2000/svg" width="1920" viewBox="0 0 1920 126">
<path fill="#FFF" fill-rule="evenodd" d="M9.09494702e-13,7.95807864e-13 L1920,7.95807864e-13 L1920,22.1174168 C1622.41146,91.3724723 1302.41146,126 960,126 C617.588542,126 297.588542,91.3724723 9.09494702e-13,22.1174168 L9.09494702e-13,7.95807864e-13 Z" transform="rotate(180 960 63)"></path>
</svg>
</div>
<div class="pageHeader__decor animate animate--wrapper">
<div class="pageHeader__decor-1 animate__child">
</div>
<div class="pageHeader__decor-2 animate__child">
</div>
</div>
</div>
<div class="blog">
<div class="container">
<div class="blog__tags animate">
<?php
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
) );
$active = "";
if ( null == #$_GET['category_id'] ) {
$active = "active";
}
echo '<a class="blog__tag '.$active.'" href="'. site_url() .'/blog">All Categories</a>';
foreach( $categories as $category ) {
$active = "";
if ( $category->name == #$_GET['category_id']) {
$active = "active";
}
echo '<a class="blog__tag '.$active.'" href="'. site_url() .'/blog?category_id='.$category->name.'">'.$category->name.'</a>';
}
?>
</div>
<div class="blog__wrapper">
<?php
$args = array(
'posts_per_page' => 1,
'post__in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1,
'category_name' => #$_GET['category_id']
);
$sticky_query = new WP_Query( $args );
while ( $sticky_query->have_posts() ) : $sticky_query->the_post();
?>
<a class="newsCard newsCard--big animate" href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail( get_the_ID() ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); ?>
<div class="newsCard__image"><img src="<?php echo $image[0]; ?>" alt=""/></div>
<?php endif; ?>
<div class="newsCard__content">
<div class="newsCard__tag">
<?php
$categories="";
foreach((get_the_category()) as $category){
$categories = $category->name.",";
}
echo substr($categories, 0, -1);
?>
</div>
<div class="newsCard__title"><?php the_title(); ?>
</div>
<div class="newsCard__description"><?php the_excerpt(); ?>
</div>
<div class="newsCard__link">Learn more
<div class="newsCard__link-icon">
</div>
</div>
</div>
</a>
<?php
endwhile;
wp_reset_postdata();
?>
<?php
$load = 0;
$total_post =wp_count_posts()->publish;
if (null !== #$_GET['load']){
$load = $_GET['load'];
}
$i = 6 + $load;
?>
<?php
// the query
$wpb_all_query = new WP_Query(array(
'post_type'=>'post',
'post_status'=>'publish',
'posts_per_page'=>$i,
'ignore_sticky_posts' => 1,
'category_name' => #$_GET['category_id']
));
$count = $wpb_all_query->found_posts;
?>
<?php if ( $wpb_all_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<a class="newsCard newsCard animate" href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail( get_the_ID() ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); ?>
<div class="newsCard__image"><img src="<?php echo $image[0]; ?>" alt=""/></div>
<?php endif; ?>
<div class="newsCard__content">
<div class="newsCard__tag">
<?php
$categories="";
foreach((get_the_category()) as $category){
$categories = $category->name.",";
}
echo substr($categories, 0, -1);
?>
</div>
<div class="newsCard__title"><?php the_title(); ?>
</div>
<div class="newsCard__description"><?php the_excerpt(); ?>
</div>
<div class="newsCard__link">Learn more
<div class="newsCard__link-icon">
</div>
</div>
</div>
</a>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
<?php if( null == #$_GET['load'] && $count > 6 ) : ?>
<div class="blog__button animate">
<?php
if ( null == #$_GET['category_id'] ) {
?>
<a class="btn" href="<?php echo site_url(); ?>/blog?load=<?php echo $load + $total_post; ?>"><?php the_field('load_more_button_label'); ?></a>
<?php
} else {
?>
<a class="btn" href="<?php echo site_url(); ?>/blog?category_id=<?php echo $_GET['category_id']; ?>&load=<?php echo $load + $total_post; ?>"><?php the_field('load_more_button_label'); ?></a>
<?php
}
?>
</div>
<?php endif; ?>
</div>
</div>
<div class="achievments">
<div class="container">
<div class="blockTitle blockTitle--center blockTitle--small">
<h2><?php the_field('achievement_title'); ?></h2>
</div>
<div class="rewardsCards2 animate animate--wrapper">
<?php
// the query
$wpb_all_query = new WP_Query(array(
'post_type'=>'achievement_cpt',
'post_status'=>'publish',
'posts_per_page'=>-1,
// 'ignore_sticky_posts' => 1,
// 'meta_key' => 'departament',
// 'meta_value' => 'Information Technology and Security'
));
?>
<?php if ( $wpb_all_query->have_posts() ) : ?>
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<div class="rewardsCards2__item animate__child"><img src="<?php echo get_field('image', get_the_ID()); ?>" alt=""/>
<div class="rewardsCards2__tooltip">
<div class="rewardsCards2__tooltip-logo"><img src="<?php echo get_field('image', get_the_ID()); ?>" alt=""/>
</div>
<div class="rewardsCards2__tooltip-content">
<div class="rewardsCards2__tooltip-title"><?php echo get_field('title', get_the_ID());?>
</div>
<div class="rewardsCards2__tooltip-description"><?php echo get_field('content', get_the_ID());?>
</div><a class="rewardsCards2__tooltip-link" href="<?php echo get_field('url',get_the_ID());?>">Read More</a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer('phone'); ?>
</div>
</body>
<?php get_footer(); ?>
So I'm not going to repeat what's already said in the article, but I hope these help you:
Remove the $load (or $_GET['load']) and $i part:
// Find and remove this:
$load = 0;
$total_post =wp_count_posts()->publish;
if (null !== #$_GET['load']){
$load = $_GET['load'];
}
$i = 2 + $load;
Add paged in the first // the query. We also set a static posts_per_page, although you may make it dynamic later.
// Find and replace this:
// the query
$wpb_all_query = new WP_Query(array(
'post_type'=>'post',
'post_status'=>'publish',
'posts_per_page'=>$i,
'ignore_sticky_posts' => 1,
'category_name' => #$_GET['category_id'],
));
$count = $wpb_all_query->found_posts;
// With this one:
// the query
$wpb_all_query = new WP_Query(array(
'post_type'=>'post',
'post_status'=>'publish',
// Set a static posts_per_page value.
'posts_per_page'=> 6,
'ignore_sticky_posts' => 1,
'category_name' => #$_GET['category_id'],
// Add the "paged" arg.
'paged' => max( get_query_var( 'paged' ), 1 ),
));
// The $count is not needed (anymore).
After that, find and replace this:
<?php if( null == #$_GET['load'] && $count > 6 ) : ?>
<div class="blog__button animate">
<?php
if ( null == #$_GET['category_id'] ) {
?>
<a class="btn" href="<?php echo site_url(); ?>/blog?load=<?php echo $load + $total_post; ?>"><?php the_field('load_more_button_label'); ?></a>
<?php
} else {
?>
<a class="btn" href="<?php echo site_url(); ?>/blog?category_id=<?php echo $_GET['category_id']; ?>&load=<?php echo $load + $total_post; ?>"><?php the_field('load_more_button_label'); ?></a>
<?php
}
?>
</div>
<?php endif; ?>
With one of the following, whichever you prefer (either simple or numerical pagination):
1) Simple previous-and-next Pagination
Here, we are using previous_posts_link() and next_posts_link().
<?php
if ( $wpb_all_query->max_num_pages > 1 ) :
$paged = max( get_query_var( 'paged' ), 1 );
?>
<div class="simple-pagination"><?php
previous_posts_link( '← Older Posts' );
if ( $paged > 1 && $paged < $wpb_all_query->max_num_pages ) {
echo ' <span class="sep">•</span> ';
}
next_posts_link( 'Newer Posts →', $wpb_all_query->max_num_pages );
?></div>
<?php endif; ?>
2) Numerical Pagination
Here, we are using paginate_links() — please check the function reference for more details on the parameters.
<?php
$links = paginate_links( array(
'total' => $wpb_all_query->max_num_pages,
'prev_text' => '← Older Posts',
'next_text' => 'Newer Posts →',
) );
if ( $links ) {
echo "<div class='numeric-pagination'>$links</div>";
}
?>
Two important things to note:
In your new WP_Query() call, the args need to have the paged arg so that WordPress knows the current page number and then retrieves only the posts for that specific page.
With next_posts_link() and paginate_links(), you need to pass the $wpb_all_query->max_num_pages which is the total number of pages for your custom WordPress query (WP_Query).
That's all, and once again, I hope this answer helps and note that I used only basic HTML in my examples above, so just modify it to your liking.
Paste this code in functions.php
<?php
//Custom pagination
function the_pagination() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<ul class="pagination " itemscope itemtype="http://schema.org/SiteNavigationElement/Pagination">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( ' <li class="page-item">%s</li>
' . "\n", get_previous_posts_link('
<span aria-hidden="true" class="page-link ripple">«</span>
<span class="sr-only">Previous</span>
') );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="page-item active"' : '';
printf( '<li%s class="page-item">%s</li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="page-item active"' : '';
printf( '<li%s class="page-item">%s</li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="page-item active"' : '';
printf( '<li%s class="page-item">%s</li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="page-item ">%s</li>
' . "\n", get_next_posts_link('<span aria-hidden="true" class="page-link ripple">»</span>
<span class="sr-only">Next</span>') );
echo '</ul>' . "\n";
}
?>
And use <?php the_pagination(); ?> where you want the pagination
Im trying to add a pagination to my post query.
I tried all the samples i found in the internet to add a pagination without any success :/
This is my query code with the pagination code I tried:
<?php
$count = 0;
// Query Code
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$wpb_all_query = new WP_Query(array('post_type'=>'post', 'category_name' => 'Recognitions', 'post_status'=>'publish', 'posts_per_page=3&paged=' . $paged));
if ( $wpb_all_query->have_posts() ) :
while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post();
?>
<?php $linktab = 'http://' . "localhost:8888/Lemon/wordpress/?page_id=158" ."&featuredimage=".get_the_post_thumbnail_url(); ?>
<div class="wraper-tab
<?php
$count++;
$current_image = $_GET["featuredimage"];
if (!isset($current_image) && $count == 1) {
$_GET["featuredimage"] = get_the_post_thumbnail_url();
$current_image = get_the_post_thumbnail_url();
}
if ($current_image == get_the_post_thumbnail_url()) {
echo "active";
}
?>
">
<a class="mitch-button to-load dark" href="<?php echo $linktab ?>" data-i="1" data-title="Lapka">
<article class="tab vertical-center" data-background-l="dark" data-background-p="dark" itemscope itemtype="http://schema.org/CreativeWork">
<header class="page-header caption">
<div>
<h6 class="tab-date"><?php echo get_the_date(); ?></h6>
<h2 class="title" itemprop="name"><?php the_title(); echo $count;?></h2>
</div>
</header>
<div class="media">
<img src="" />
</div>
</article>
</a>
</div>
<?php endwhile; ?>
<?php
else :
_e( 'Sorry, no posts matched your criteria.' );
endif;
?>
</div>
<?php
// Pagination code
next_posts_link();
previous_posts_link();
?>
I want to make so that it shows 3 posts per page. thats why I added 3 in the posts_per_page parameter.
I want a numbered list.
Please use this code
<?php $count = 0; $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $wpb_all_query = new WP_Query(array('post_type'=>'post', 'category_name' => 'Recognitions', 'post_status'=>'publish', 'posts_per_page'=>3, 'paged' => $paged )); $wpb_all_query->query_vars[ 'paged' ] > 1 ? $current = $wpb_all_query->query_vars[ 'paged' ] : $current = 1;
$pagination = array(
'base' => 'page/%#%',
//'format' => '',
'showall' => false,
'end_size' => 1,
'mid_size' => 6,
'total' => $wpb_all_query->max_num_pages,
'current' => $current,
'prev_text' => __('←'),
'next_text' => __('→'),
'type' => 'list'
);
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = str_replace('&page='.$current, '', $actual_link);
global $wp_rewrite;
if ( $wp_rewrite->using_permalinks() )
$pagination[ 'base' ] = $url. '&page=%#%' ;
if ( $wpb_all_query->have_posts() ) :
while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post();
?>
<?php $linktab = 'http://' . "localhost:8888/Lemon/wordpress/?page_id=158" ."&featuredimage=".get_the_post_thumbnail_url(); ?>
<div class="wraper-tab
<?php
$count++;
$current_image = $_GET["featuredimage"];
if (!isset($current_image) && $count == 1) {
$_GET["featuredimage"] = get_the_post_thumbnail_url();
$current_image = get_the_post_thumbnail_url();
}
if ($current_image == get_the_post_thumbnail_url()) {
echo "active";
}
?>
">
<a class="mitch-button to-load dark" href="<?php echo $linktab ?>" data-i="1" data-title="Lapka">
<article class="tab vertical-center" data-background-l="dark" data-background-p="dark" itemscope itemtype="http://schema.org/CreativeWork">
<header class="page-header caption">
<div>
<h6 class="tab-date"><?php echo get_the_date(); ?></h6>
<h2 class="title" itemprop="name"><?php the_title(); echo $count;?></h2>
</div>
</header>
<div class="media">
<img src="" />
</div>
</article>
</a>
</div>
<?php endwhile; ?>
<?php
else :
_e( 'Sorry, no posts matched your criteria.' );
endif;
?>
</div><nav class="woocommerce-pagination"><?php echo paginate_links($pagination); ?></nav>
I want to display a simple front page with 2 categories,
But when I enter 2 same code, the result is empty,
But one code, the result appears
I look like:
Title: chicken category
Content
Title: cow category
Content
I tried with a simple php code:
<h2 class="home1">10 Best Chicken</h2>
<div class="1"><?php query_posts('cat=9' . '&showposts=3'.'&paged='.$paged); ?></div>
<h2 class="home1">10 Best Cow</h2>
<div class="1"><?php query_posts('cat=10' . '&showposts=3'.'&paged='.$paged); ?></div>
How the best solution?
Don't use query_posts , use WP_Query instead
<?php get_header(); ?>
<?php if((is_home())&& ($paged < 1)) { ?>
<?php get_template_part( 'home-featured' ); ?>
<?php } ?>
<div class="wisata-konten">
<div class="container">
<div class="row">
<div class="col-md-12">
<?php if((is_home())&& ($paged > 1)) { ?>
<h1><?php bloginfo('name'); ?> - <?php if ( get_query_var('paged') ) { echo 'Halaman '. get_query_var('paged'); } ?></h1>
<?php } ?>
<div class="row"><div class="boxer2">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="col-md-4"><?php get_template_part( 'thumb' ); ?></div>
<?php endwhile; ?></div></div>
<?php fastestwp_pagenavi(); ?>
<?php else : ?>
<h2>Not Found</h2>Sorry, but you are looking for something that isn't here.
<?php endif; ?>
<h2 class="home1">Lombok Open Trip</h2>
<?php $args = array( 'cat' => 9 , 'posts_per_page' => 3 , 'paged' => $paged );
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
?><h2 class="home1">Lombok Promo</h2><?php
$args2 = array( 'cat' => 10 , 'posts_per_page' => 3 , 'paged' => $paged );
$the_query2 = new WP_Query( $args2 );
// The Loop
if ( $the_query2->have_posts() ) {
echo '<ul>';
while ( $the_query2->have_posts() ) {
$the_query2->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
} ?>
<div class="wisata-testimoni">
<div class="container">
<div class="row">
<div class="col-md-12">
<div id="testimoni" class="carousel slide">
<div class="carousel-inner">
<?php fastestwp_comments(); ?>
</div>
</div>
<div class="tombol"><a class= "medium beli blue pull-right" href="<?php echo home_url() ; ?>/testimoni" >Lihat Semua Testimoni <span class="glyphicon glyphicon-thumbs-up"></span></a></div>
</div>
</div>
</div>
</div>
I'm about to finish a wordpress-site with a custom theme and several custom-post-types. Now i wanted to change the permalink settings to %post-name%, to make the url's nicer and this is where the problems start.
I have 3 custom-post-types next to the default post-format: events, galleries, shop. Now when I load the page "events (using the template-events.php, what does a wp_query to get all the events), I get all posts. It basically ignores the defined template and loads the one defined for the posts-page, same happens for the shop-page.
The strange thing is that the gallery page (loading the same kind of template file to do the wp_query) works fine.
When I change back to the default permalink-setting everything works fine...
Thanks for any hint!
here my template-events.php
<?php
/*
Template Name: Events
*/
?>
<?php get_header(); ?>
<?php
//Fix homepage pagination
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$now = strtotime("now");
$args = array(
'post_type' => 'events',
'posts_per_page' => 40,
'post_status' => 'publish',
'meta_key' => '_cmb_date_timestamp',
'orderby' => 'meta_value',
'order' => 'ASC',
'paged' => $paged,
'meta_query' => array(
array(
'key' => '_cmb_date_timestamp',
'value' => $now,
'type' => 'NUMERIC',
'compare' => '>=' )
)
);
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
// posts in the last 30 days
$where .= " AND _cmb_date_timestamp < '" . date('Y-m-d') . "'";
return $where;
}
//add_filter( 'posts_where', 'filter_where' );
$events_query = new WP_Query($args);
if( $events_query->have_posts() ) :
$derLudwig = get_theme_mod( 'eventsHeading', '');
$url = esc_url( get_theme_mod( 'events_image' ) );
echo '<div class="overview-header" style="background-image: url('.$url.');"></div>';
echo '<h2 class="overview">der Ludwig '.$derLudwig.'</h2>';
?>
<div id="filters">
<div id="filterButtons">
<a id="filterOpen" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/sub-navi2.png"/></a>
<a id="filterClose" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/filter-close.png"/></a>
</div>
<?php
/* FILTERS */
$args = array(
'type' => 'events',
'taxonomy' => 'event_category',
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
echo '<div id="categories">';
echo '<h5>Kategorien: </h5>';
echo '<ul>';
foreach ($categories as $category) {
echo '<li>' . $category->name . '</li>';
}
echo '</ul>';
echo '</div>';
?>
Clear
</div>
<!--BEGIN #content -->
<div id="content" class="clearfix">
<?php
echo '<img class="loader" src="'.get_bloginfo('template_url').'/images/loader.gif"/>';
echo '<div id="primary" class="hfeed event-overview">';
while( $events_query->have_posts() ) : $events_query->the_post();
// infos
$time = get_post_meta($post->ID, '_cmb_time', true);
$cdateStamp = get_post_meta($post->ID, '_cmb_date_timestamp');
$monthName = date_i18n('F', $cdateStamp[0]);
$weekdayNumber = date_i18n('j', $cdateStamp[0]);
$weekday = date_i18n('D', $cdateStamp[0]);
$locations = get_the_terms( $post->ID, 'locations' );
$tickets = get_post_meta($post->ID, '_ludwig_events_tickets', true);
$featured = get_post_meta($post->ID, '_ludwig_events_display_featured', true);
$reservation = get_post_meta($post->ID, '_ludwig_events_display_reservation', true);
// grab everything else
$custom_bg = get_post_meta($post->ID, '_zilla_portfolio_display_background', true);
$portfolio_caption = get_post_meta($post->ID, '_zilla_portfolio_caption', true);
?>
<?php
if(!isset($currentMonth) || $currentMonth != $monthName){
?>
<h2 class="<?php echo lcfirst($monthName); ?>"><?php echo $monthName; ?></h2>
<?php
}
$currentMonth = $monthName;
?>
<!--BEGIN .hentry-->
<div id="post-<?php the_ID(); ?>" class="event-small <?php echo lcfirst($monthName); ?>">
<!--BEGIN .entry-content -->
<div class="entry-content">
<div class="eTop">
<span class="dateDay"><?echo $weekdayNumber; ?></span>
<span class="dateMonth"><? _e($monthName, 'ludwig-events'); ?></span>
<span class="dateWeekDay"><? _e($weekday, 'ludwig-events'); ?></span>
</div>
<?php the_post_thumbnail('event-small'); ?>
<div class="eBottom">
<?php the_title('<h3>', '</h3>'); ?>
<span class="eventWo">
<?php
if ( $locations && !is_wp_error( $locations ) ) {
foreach ( $locations as $location ) {
echo $location->name;
}
}
?>
, <?php echo $time; ?>Uhr</span>
<div class="event-buttons">
<div class="inner">
<div class="centerContainer">
<h4>Tickets</h4>
<?php ticketsLink($tickets); ?>
<?php reservationLink($reservation); ?>
</div>
</div>
</div>
</div>
<!--END .entry-content -->
</div>
</div>
<?php endwhile; ?>
<!--END #primary .hfeed-->
</div>
<?php else: ?>
<div id="content" class="nocontent">
<!--BEGIN #post-0-->
<div id="post-0" <?php post_class(); ?>>
<h2 class="entry-title"><?php _e('Keine Events gefunden', 'ludwig') ?></h2>
<!--BEGIN .entry-content-->
<div class="entry-content">
<p><?php _e("Hoppala, das sollte eigentlich nicht passieren", "ludwig") ?></p>
<!--END .entry-content-->
</div>
<!--END #post-0-->
</div>
</div>
<?php endif; ?>
<?php remove_filter( 'posts_where', 'filter_where' ); ?>
<?php get_footer(); ?>
here the working template-gallery.php
<?php
/*
Template Name: Fotos
*/
?>
<?php get_header(); ?>
<?php
//Fix homepage pagination
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
// CHECK THAT THIS ONE ISTN DOWN
/*
$args = array(
'post_type' => 'gallery',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'modified',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'gallery_category',
'field' => 'id',
'terms' => array( $term_id ),
'operator' => 'IN'
)
),
'paged' => $paged
);
$sina_query = new WP_Query($args);
$sinaString = '';
if( $posts_query->have_posts() ) :
while( $posts_query->have_posts() ) : $posts_query->the_post();
?>
<?php endwhile; ?>
<?php endif; ?>
*/
$args = array(
'post_type' => 'gallery',
'orderby' => 'modified',
'order' => 'DESC',
'posts_per_page' => 10,
'paged' => $paged
);
$posts_query = new WP_Query($args);
if( $posts_query->have_posts() ) :
$derLudwig = get_theme_mod( 'fotosHeading', '');
$url = esc_url( get_theme_mod( 'fotos_image' ) );
echo '<div class="overview-header" style="background-image: url('.$url.');"></div>';
echo '<h2 class="overview">der Ludwig '.$derLudwig.'</h2>';
?>
<div id="filters">
<div id="filterButtons">
<a id="filterOpen" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/sub-navi2.png"/></a>
<a id="filterClose" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/filter-close.png"/></a>
</div>
<?php
/* FILTERS */
$args = array(
'type' => 'events',
'taxonomy' => 'gallery_category',
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
echo '<div id="categories">';
echo '<h5>Kategorien: </h5>';
echo '<ul>';
foreach ($categories as $category) {
echo '<li>' . $category->name . '</li>';
}
echo '</ul>';
echo '</div>';
?>
Clear
</div>
<!--BEGIN #content -->
<div id="content" class="clearfix">
<?php
echo '<img class="loader" src="'.get_bloginfo('template_url').'/images/loader.gif"/>';
echo '<div id="primary" class="hfeed gallery-overview">';
$counter = 0;
while( $posts_query->have_posts() ) : $posts_query->the_post();
$fotograf = get_post_meta($post->ID, '_ludwig_gallery_fotograf', true);
?>
<?php
if ($counter == 1) {
?>
<div id="post-<?php the_ID(); ?>" class="gallery-grid post-<?php echo $counter++; ?>">
<!--BEGIN .entry-content -->
<div class="entry-content">
<a href="<?php echo get_permalink(); ?>">
<div class="overlayContainer">
<div class="overlay">
<div class="content">
<div class="inner">
<?php
/*
$terms = get_the_terms( $post->ID, 'gallery_category');
if ( $terms && ! is_wp_error( $terms ) ) :
$draught_links = array();
foreach ( $terms as $term ) {
$draught_links[] = $term->name;
}
$on_draught = join( ", ", $draught_links );
*/
?>
<p class="galleryCategories">
<span><?php //echo $on_draught; ?></span>
</p>
<?php //endif; ?>
<h3><?php the_title(); ?></h3>
<p class="fotograf">von<br><span><?php echo $fotograf; ?></span></p>
</div>
</div>
</div>
</div>
<?php the_post_thumbnail('gallery-mid'); ?></a>
</div>
</div>
<?php echo $counter++; ?>
<?php
} else {
?>
<div id="post-<?php the_ID(); ?>" class="gallery-grid post-<?php echo $counter++; ?>">
<!--BEGIN .entry-content -->
<div class="entry-content">
<a href="<?php echo get_permalink(); ?>">
<div class="overlayContainer">
<div class="overlay">
<div class="content">
<div class="inner">
<?php
/*
$terms = get_the_terms( $post->ID, 'gallery_category');
if ( $terms && ! is_wp_error( $terms ) ) :
$draught_links = array();
foreach ( $terms as $term ) {
$draught_links[] = $term->name;
}
$on_draught = join( ", ", $draught_links );
*/
?>
<p class="galleryCategories">
<span><?php //echo $on_draught; ?></span>
</p>
<?php //endif; ?>
<h3><?php the_title(); ?></h3>
<p class="fotograf">von<br><span><?php echo $fotograf; ?></span></p>
</div>
</div>
</div>
</div>
<?php the_post_thumbnail('gallery-mid'); ?></a>
</div>
</div>
<?php } ?>
<?php endwhile; ?>
<!--END .hfeed -->
</div>
<a class="archivlink" href="#">⌸ Archiv</a>
<div class="navigation">
<div class="next-posts"><?php next_posts_link('« Older Entries', $posts_query->max_num_pages) ?></div>
<div class="prev-posts"><?php previous_posts_link('Newer Entries »', $posts_query->max_num_pages) ?></div>
</div>
<?php else: ?>
<div id="content" class="nocontent">
<!--BEGIN #post-0-->
<div id="post-0" <?php post_class(); ?>>
<h2 class="entry-title"><?php _e('Keine Fotos gefunden', 'ludwig') ?></h2>
<!--BEGIN .entry-content-->
<div class="entry-content">
<p><?php _e("Hoppala, das sollte eigentlich nicht passieren", "ludwig") ?></p>
<!--END .entry-content-->
</div>
<!--END #post-0-->
</div>
</div>
<?php endif; ?>
<?php get_footer(); ?>
Hint from me (Since you do not put a code):
Nothing wrong with the permalink. It should be work. I believe what cause this is your code. Please, double check your code and re-install your WordPress, and try again.
Here is, index.php file from my template.
<?php get_header(); ?>
<div id="content">
<div id="content_inside">
<?php
wp_reset_query();
$get_blog_id = '-' . get_category_id('blog');
if(get_category_id('blog') != '') {
$args = array(
'post_type' => 'post',
'cat' => $get_blog_id,
'posts_per_page' => 6,
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)
);
} else {
$args = array(
'post_type' => 'post',
'posts_per_page' => 6,
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)
);
}
query_posts($args);
$x = 0;
while (have_posts()) : the_post(); ?>
<?php if($x % 2 == 0) { ?>
<div class="post_box">
<?php } else { ?>
<div class="post_box post_box_right">
<?php } ?>
<?php if ($x == 0) { ?>
<h1><?php the_title(); ?></h1>
<?php } elseif ($x == 1 || $x == 2 || $x == 3) { ?>
<h2><?php the_title(); ?></h2>
<?php } elseif ($x == 4 || $x == 5) { ?>
<h3><?php the_title(); ?></h3>
<?php } else { ?>
<h3><?php the_title(); ?></h3>
<?php } ?>
<div class="post_meta"><?php the_author(); ?> / <?php the_time('d m , Y') ?> - <?php the_time('H:i'); ?> / <?php comments_popup_link('Yorum Yok', '1 Yorum', '% Yorum'); ?></div>
<div class="img_link">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('featured-home'); ?>
<?php
//$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'featured-home' );$url = $thumb['0'];
//$titleGet = get_the_title($post->ID);
//echo '<img src="'.CDN.'/assets/images/_load.png" alt="'.$titleGet.'" data-modafesto="'.$url.'" width="301" height="398" />';
?>
</a>
</div>
<div class="post_cat">
<?php
$category = get_the_category();
echo ''.$category[0]->cat_name.'';
?> konu başlığı ile yayınlandı.
</div>
</div><!--//post_box-->
<?php if($x % 2 == 1) { ?>
<div class="clear"></div>
<?php } ?>
<?php $x++; ?>
<?php endwhile; ?>
<div class="clear"></div>
</div><!--//content_inside-->
<div class="clear"></div>
<div class="load_more_cont">
<div style="margin:0px auto;"><div class="load_more_text"><?php next_posts_link('DİĞER YAZILARI YÜKLE') ?></div></div>
</div><!--//load_more_cont-->
<?php wp_reset_query(); ?>
</div><!--//content-->
<script type="text/javascript">$(".load_more_cont a").live("click",function(a){a.preventDefault();$(".load_more_text a").html("Yazılar Yükleniyor...");$.ajax({type:"GET",url:$(this).attr("href")+"#content",dataType:"html",success:function(b){result=$(b).find("#content_inside .post_box");nextlink=$(b).find(".load_more_cont a").attr("href");$("#content_inside").append(result);$(".load_more_text a").html("Daha fazla yazı yükle");if(nextlink!=undefined){$(".load_more_cont a").attr("href",nextlink)}else{$(".load_more_cont").remove();$("#content_inside").append('<div class="clear"></div>')}}})});</script>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I have tried to use, lazy load script for my images. Because it is a great choice for SEO Engines. That lines,
<div class="img_link">
<a href="<?php the_permalink(); ?>">
<?php
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'featured-home' );$url = $thumb['0'];
$titleGet = get_the_title($post->ID);
echo '<img src="'.CDN.'/assets/images/_load.png" alt="'.$titleGet.'" data-modafesto="'.$url.'" width="301" height="398" />';
?>
</a>
</div>
Also, here is my preloader script http://j.mp/12QkkTW .
When you load the page, first posts comes corectly with lazyload / preload but if you click load more posts button, when you get more posts the preloader doesnt work.
Can anyone help me ? Thank you.
try to add
$("XXXXXXX img").lazyload();
in ajax success callback funcion, after append html,
XXXXX is append html DOM, eq: class name or id