page / 2 / is going but the homepage always appears help
<div class="row">
<div class="col-md-8">
<?php $query = new WP_Query('post_type=homee');?>
<?php if ( $query->have_posts() ) : while ($query->have_posts() ) : $query->the_post();?>
<div class="card mt-4">
<a href="<?php the_field('homecard-link');?>" class='card-header-h'><h3
class="card-title m-2">
<div class="card-footer text-muted ">
<i class="fas fa-table text-warning"></i>
Post Tarihi <?php the_field('homepost-history');?>
</div>
<a href="<?php the_field('homecard-link');?>"><img src="<?php
the_field('homeimage');?>" class="card-img-top img-thumbnail">
<div class="card-body">
<p class="card-text"><?php the_field('homecard-text');?></p>
<a class="more" href="<?php the_field('homecard-link');?>"><button
type="button" class="btn btn-dark more"> Devamını Oku
</div>
<?php endwhile; ?>
<?php else : ?>
<p><?php esc_html_e( 'Üzgünüz, Sayfa Bulunamadı' ); ?></p>
<?php endif;
wp_pagenavi(array( 'query' => $query )); `this problem`
wp_reset_query(); `this problem`
;?>
Please try and replace wp query
<?php $query = new WP_Query('post_type=homee', 'paged' => get_query_var( 'paged' ));?>
Related
I am trying to redirect the user to the first page of the pagination if the pagination is empty.
I have three bootstrap tabs (Both, Blog, News). The blog tab contains 5 posts. The news tab contains more than 12 posts. I am displaying 6 posts per page. The issue here is that if I am on the second page of News tab and click the Blog tab, the second page of the blog tab is opening (which does not exist).
For better Understanding Here is my code.
<ul class="nav nav-tabs" id="myTab">
<li class="nav-item">
Section A
</li>
<li class="nav-item">
Section B
</li>
<li class="nav-item">
Section C
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div id="sectionA" class="tab-pane fade show active">
<?php
if(1 != $paged) {
}
?>
<section class="vendor-section-2 mt-5">
<div class="container">
<div class="row">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$the_query = new WP_Query(
array(
'posts_per_page' => 6,
'post_type' => 'post',
'paged' => $paged
)
);
$page_amount = $the_query->max_num_pages;
?>
<div class="container pagination-count">
<div class="row">
<div class="col-6">
<p>Page <span><?php echo $paged ?></span> of <span><?php echo $page_amount ?></span> </p>
</div>
</div>
</div>
<?php
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post();
$post_id = get_the_ID();
?>
<div class="col-md-4 mt-5">
<div class="card">
<img src="<?php the_post_thumbnail_url() ?>" class="card-img-top" alt="...">
<div class="card-body">
<h2 class="card-title"><?php the_title() ?></h2>
<p class="card-text"><?php the_excerpt(); ?></p>
<a href="<?php the_permalink() ?>" class="read-more" >
<svg xmlns="http://www.w3.org/2000/svg" width="24.111" height="23.646" viewBox="0 0 24.111 23.646" style="margin-right: 10px; margin-top: -5px;">
<path
id="Path_84"
data-name="Path 84"
d="M9.544.241a3.061,3.061,0,0,1,3.348.642c1.4,1.427,4.322,1.638,5.638,2.976,1.49,1.518,1.358,4.151,2.856,5.584a7.9,7.9,0,0,1,2.163,8.913,7.942,7.942,0,0,1-3.789,4.323c-6.319,2.6-14.617-.268-18.3-5.889-1.8-2.745-2.12-6.848.122-9.133C3.947,5.245,5.608,1.887,9.544.241Z"
fill="#f3943f"
/>
</svg>
Read More
</a>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
endif;?>
<div class="next-prev-btn">
<!-- then the pagination links -->
<?php next_posts_link( 'Next →', $the_query ->max_num_pages); ?>
<?php previous_posts_link( 'Previous ← ' ); wp_reset_query();?>
</div>
</div>
</div>
</section>
</div>
<div id="sectionB" class="tab-pane fade">
<section class="vendor-section-2 mt-5">
<div class="container">
<div class="row">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$the_query = new WP_Query(
array(
'posts_per_page' => 6,
'post_type' => 'post',
'category_name' => 'blog',
'paged' => $paged
)
);
$page_amount = $the_query->max_num_pages;
?>
<div class="container pagination-count">
<div class="row">
<div class="col-6">
<p>Page <span><?php echo $paged ?></span> of <span><?php echo $page_amount ?></span> </p>
</div>
</div>
</div>
<?php
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post();
$post_id = get_the_ID();
?>
<div class="col-md-4 mt-5">
<div class="card">
<img src="<?php the_post_thumbnail_url() ?>" class="card-img-top" alt="...">
<div class="card-body">
<h2 class="card-title"><?php the_title() ?></h2>
<p class="card-text"><?php the_excerpt(); ?></p>
<a href="<?php the_permalink() ?>" class="read-more" >
<svg xmlns="http://www.w3.org/2000/svg" width="24.111" height="23.646" viewBox="0 0 24.111 23.646" style="margin-right: 10px; margin-top: -5px;">
<path
id="Path_84"
data-name="Path 84"
d="M9.544.241a3.061,3.061,0,0,1,3.348.642c1.4,1.427,4.322,1.638,5.638,2.976,1.49,1.518,1.358,4.151,2.856,5.584a7.9,7.9,0,0,1,2.163,8.913,7.942,7.942,0,0,1-3.789,4.323c-6.319,2.6-14.617-.268-18.3-5.889-1.8-2.745-2.12-6.848.122-9.133C3.947,5.245,5.608,1.887,9.544.241Z"
fill="#f3943f"
/>
</svg>
Read More
</a>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
endif;?>
<div class="next-prev-btn">
<!-- then the pagination links -->
<?php next_posts_link( 'Next →', $the_query ->max_num_pages); ?>
<?php previous_posts_link( 'Previous ← ' ); wp_reset_query();?>
</div>
</div>
</div>
</section>
</div>
<div id="sectionC" class="tab-pane fade">
<section class="vendor-section-2 mt-5">
<div class="container">
<div class="row">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$the_query = new WP_Query(
array(
'posts_per_page' => 6,
'post_type' => 'post',
'category_name' => 'news',
'paged' => $paged
)
);
$page_amount = $the_query->max_num_pages;
?>
<div class="container pagination-count">
<div class="row">
<div class="col-6">
<p>Page <span><?php echo $paged ?></span> of <span><?php echo $page_amount ?></span> </p>
</div>
</div>
</div>
<?php
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post();
$post_id = get_the_ID();
?>
<div class="col-md-4 mt-5">
<div class="card">
<img src="<?php the_post_thumbnail_url() ?>" class="card-img-top" alt="...">
<div class="card-body">
<h2 class="card-title"><?php the_title() ?></h2>
<p class="card-text"><?php the_excerpt(); ?></p>
<a href="<?php the_permalink() ?>" class="read-more" >
<svg xmlns="http://www.w3.org/2000/svg" width="24.111" height="23.646" viewBox="0 0 24.111 23.646" style="margin-right: 10px; margin-top: -5px;">
<path
id="Path_84"
data-name="Path 84"
d="M9.544.241a3.061,3.061,0,0,1,3.348.642c1.4,1.427,4.322,1.638,5.638,2.976,1.49,1.518,1.358,4.151,2.856,5.584a7.9,7.9,0,0,1,2.163,8.913,7.942,7.942,0,0,1-3.789,4.323c-6.319,2.6-14.617-.268-18.3-5.889-1.8-2.745-2.12-6.848.122-9.133C3.947,5.245,5.608,1.887,9.544.241Z"
fill="#f3943f"
/>
</svg>
Read More
</a>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
endif;?>
<div class="next-prev-btn">
<!-- then the pagination links -->
<?php next_posts_link( 'Next →', $the_query ->max_num_pages); ?>
<?php previous_posts_link( 'Previous ← ' ); wp_reset_query();?>
</div>
</div>
</div>
</section>
</div>
</div>
<script>
$(document).ready(function(){
$('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
localStorage.setItem('activeTab', $(e.target).attr('href'));
});
var activeTab = localStorage.getItem('activeTab');
if(activeTab){
$('#myTab a[href="' + activeTab + '"]').tab('show');
}
});
</script>
I'm new to WordPress, and I've created a custom template, I'm facing a problem when I try to fetch the posts to the front page (homepage).
In (dashboard->Reading) I set my homepage displays as a Static page and selected Home page as (home) and Post page as (posts).
In the index.php the code that's showing the posts in Posts page is :
<section class="recent-posts" id="recent-posts">
<div class="container">
<div class="title text-center">
<h1 class="title-blue">posts</h1>
</div>
<div class="row">
<?php
while(have_posts()) {
the_post();
?>
<div class="col-lg-6">
<div class="single-rpost d-sm-flex align-items-center" data-aos="fade-right"
data-aos-duration="800">
<div class="post-thumb">
<img class="img-fluid" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="post-1">
</div>
<div class="post-content text-sm-right">
<time datetime="<?php the_time('l, jS/n/Y'); ?>">
<?php the_time('l, jS/n/Y'); ?>
</time>
<h3>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h3>
<p class="post-excerpt">
<?php echo wp_trim_words(get_the_excerpt(), 10); ?>
</p>
<p>
<!-- <a href="#"> -->
<?php echo get_the_category_list(' ') ?>
<!-- </a> -->
</p>
<a class="post-btn" href="<?php the_permalink(); ?>">
<i class="fa fa-arrow-left"></i>
</a>
</div>
</div>
</div>
<?php
}
wp_reset_query();
?>
</div>
<!-- Posts Navigation -->
</div>
</section>
<!-- Paginate through pages -->
<div class="pagination">
<?php echo paginate_links(); ?>
</div>
It works fine in posts page but when I copy the same code in page-home.php file it doesn't work and fetches no posts at all.
Sorry I'm a beginner, but I need help.
Thanks.
Try this
<?php
global $paged, $wp_query, $wp;
$args = wp_parse_args($wp->matched_query);
if ( !empty ( $args['paged'] ) && 0 == $paged ) {
$wp_query->set('paged', $args['paged']);
$paged = $args['paged'];
}
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('paged='.$paged.'&showposts=10&cat='.get_option('prototype_blog_cat'));
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="col-lg-6">
<div class="single-rpost d-sm-flex align-items-center" data-aos="fade-right"
data-aos-duration="800">
<div class="post-thumb">
<img class="img-fluid" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="post-1">
</div>
<div class="post-content text-sm-right">
<time datetime="<?php the_time('l, jS/n/Y'); ?>">
<?php the_time('l, jS/n/Y'); ?>
</time>
<h3>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h3>
<p class="post-excerpt">
<?php echo wp_trim_words(get_the_excerpt(), 10); ?>
</p>
<p>
<!-- <a href="#"> -->
<?php echo get_the_category_list(' ') ?>
<!-- </a> -->
</p>
<a class="post-btn" href="<?php the_permalink(); ?>">
<i class="fa fa-arrow-left"></i>
</a>
</div>
</div>
</div>
<?php endwhile; ?>
<span >
<?php echo paginate_links( array(
'prev_text' => '<span>Previous</span>',
'next_text' => '<span>Next</span>'
)); ?>
It should solve the problem.
I have a problem with a custom wordpress template.
I've made a categories page. Works fine on the firs view.
But when I make click on 2nd page for older posts, the browser shows me a 404 error.
I think my query needs something more, but I don't know what is or if this is the problem.
Can somebody help, please?
This is my code:
<?php
/**
* The template for displaying Category pages
*/
?>
<?php get_header(); ?>
<?php get_template_part( 'partials/linea-content', 'page' ); ?>
<div class="index categories">
<div class="col-xs-12 pre-content">
<div class="container">
<?php //Para añadir contenido se interesa ?>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12 categories-title">
<h2>Categoria: <span><?php echo get_category(get_query_var('cat'))->name; ?></span></h2>
</div>
<div id="posts" class="col-xs-12 col-sm-9">
<?php
// set the "paged" parameter (use 'page' if the query is on a static front page)
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// Cambiamos los argumentos para buscar desde la última
$args = array(
'posts_per_page' => 2,
'orderby' => 'date',
'order' => ASC,
'category__in' => get_category(get_query_var('cat'))->cat_ID,
'paged' => $paged
);
// '&orderby=date&order=ASC&category=' . get_category(get_query_var('cat'))->cat_ID;
// volvemos a crear la consulta principal
$aux = query_posts( $args );
$cont_items = 1;
?>
<?php if ( have_posts() ) : ?>
<div class="row items-row">
<div class="col-xs-12">
<?php while ( have_posts() ) : the_post(); ?>
<!-- post -->
<div id="post-id-<?php echo $post->ID; ?>" class="item col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 text-center item-content">
<span class="meta-category">
<span class="meta-category-inner">
<?php
$cat = get_the_category($post->ID);
?>
<?php echo $cat[0]->name; ?>
</span>
</span>
<?php
global $wpdb;
$ppbv_tablename = $wpdb->prefix . 'popular_by_views';
$currentRow = $wpdb->get_row("SELECT * FROM {$ppbv_tablename} WHERE post_id = {$post->ID}");
$curView = 0;
if(isset($currentRow))
{
$curView = $currentRow->views;
}
?>
<div class="item-title-content">
<a href="<?php the_permalink(); ?>" title="Popsicase">
<h2 class="item-title col-xs-10 col-xs-offset-1"><?php the_title(); ?></h2>
</a>
</div>
<p class="date-cat">
<small class="col-xs-12">
<i class="fa fa-link"></i> <strong><?php the_author(); ?></strong> | <span><i class="fa fa-calendar"></i> <?php echo get_the_date();?> | <i class="fa fa-eye"></i> <?php echo $curView; ?></span>
</small>
</p>
<?php
$img_url = get_template_directory_uri() . '/assets/img/podcast.jpg';
if (get_the_post_thumbnail())
{
$img_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
}
?>
<a href="<?php the_permalink(); ?>" title="Popsicase">
<div class="item-thumbnail" style="background:url(<?php echo $img_url; ?>) no-repeat center center;">
</div>
</a>
<div class="row">
<div class="col-xs-6 text-right">
<?php /*<span class="comment"> Comentarios: <?php comments_number( '0','1','%'); ?></span>*/ ?>
</div>
</div>
<div class="item-excerpt text-left">
<div class="col-xs-12">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
</div>
<?php if ($cont_items % 2 == 0) : ?>
</div>
</div>
<div class="row items-row">
<div class="col-xs-12">
<?php
endif;
$cont_items++;
?>
<?php endwhile; ?>
</div>
</div>
<!-- End of the main loop -->
<!-- Add the pagination functions here. -->
<?php
the_posts_pagination( array(
'mid_size' => 4,
'prev_text' => __( 'Artículos antiguos', 'textdomain' ),
'next_text' => __( 'Artículos nuevos', 'textdomain' ),
) );
?>
<?php /*
<div class="nav-previous alignleft"><?php next_posts_link( 'Artículos antiguos' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Artículos nuevos' ); ?></div>
*/ ?>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
<div class="hidden-xs col-sm-3 sidebar">
<div class="row">
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('main-sidebar')) : ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="col-xs-12 pos-content">
<div class="container">
<?php //Para añadir contenido se interesa ?>
</div>
</div>
<div class="clearfix"></div>
</div>
i'm looking a way to display the-excerpt of post when Sharing on facebook, here is my code, but it doenst show the_exceprt of the post . ..
<a <a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t= <?php the_excerpt(); ?><?php the_title(); ?>"<i class="fa fa-facebook"></i></a>
If it can help, this is the section with the all code ( it's a grid system, each box of the "grid" has different content)
<div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ccffff" >
<h1>Press room</h1>
<?php
$query = new WP_Query( array( 'post_type' => 'coverage', 'posts_per_page' => 1 ) );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
?>
<time class="timestamp"><?php the_date(); ?></time>
<h2 class="h4"><?php the_title(); ?></h2>
<div class="palm--hidden"><?php the_excerpt(); ?><p></p></div>
Read More
<div class="social-icons-2">
<ul class="hl">
<li>Share:</li>
<li><a <a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t= <?php the_excerpt(); ?><?php the_title(); ?>"<i class="fa fa-facebook"></i></a></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-pinterest"></i></li>
</ul>
</div>
<?php
endwhile; endif;
?>
</div>
</article>
</div>
ANother question related with this facebook share, at the moment it's sharing the logo of the website . . any possiblity to show insterad the picture attach of the post ?
Thank you so much for all your time in advance
EDIT: I put here all the code of the page in case it heelps . ..
<?php get_header(); ?>
<div id="slider-header">
<div class="container">
<div class="row">
<div class="col-sm-4 slider-header-left">
WHAT WE DO
</div>
<div class="col-sm-8 slider-header-right">
texttt
</div>
</div>
</div>
</div>
<div id="main" class="site-main" role="main">
<div id="home-slider">
<div class="container">
<div class="row home-content-slider">
<?php
$services = get_page_by_path('services');
if($services) $parent = $services->ID;
$the_query = new WP_Query( array( 'post_type' => 'page', 'post_per_page' => 5, 'post_parent' => $parent, 'order' => 'ASC' ) );
$service_titles = array();
$service_images = array();
if ( $the_query->have_posts() ) {
$i = 1;
while ( $the_query->have_posts() ) {
$the_query->the_post();
$service_titles[] = '<li id="nav-fragment-'. $i .'" class=""><a href="#fragment-'. $i .'" ><span>'. get_the_title() .'</span></a></li>';
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
$image = wp_get_attachment_image_src( $post_thumbnail_id, 'full' );
$service_images[] = '<div id="fragment-'. $i .'" class="ui-tabs-panel ui-tabs-hide"><img src="'. $image[0] .'" title="" /><div class="overlay-description">'. get_field('slider_text') .'</div></div>';
$i++;
}
}
wp_reset_postdata();
?>
<div class="col-sm-4 home-slider-left">
<div class="row">
<ul>
<?php echo implode( "\n", $service_titles ); ?>
</ul>
</div>
</div>
<div class="col-sm-8 home-slider-right">
<div class="row">
<?php echo implode( "\n", $service_images ); ?>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div id="grid_container">
<div class="row">
<div class="col-sm-6 news-post" style="background-color: #ccfff" data-key="newsItem">
<article class="grid row">
<div data-ratio="1" class="grid__item grid__item_inline one-half">
<?php
echo '<div class="flexslider">';
echo '<ul class="slides">';
$query = new WP_Query( array( 'post_type' => 'coverage', 'posts_per_page' => 9 ) );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
$image = wp_get_attachment_image_src( $post_thumbnail_id, 'homepage-thumb' );
if($image) echo '<li><img class="img-responsive" src="'. $image[0] .'" alt="" /></li>';
endwhile; endif;
echo '</ul>';
echo '</div>';
?>
<?php wp_reset_postdata(); ?>
</div>
<div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ccffff" >
<h1>Press room</h1>
<?php
$query = new WP_Query( array( 'post_type' => 'coverage', 'posts_per_page' => 1 ) );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
?>
<time class="timestamp"><?php the_date(); ?></time>
<h2 class="h4"><?php the_title(); ?></h2>
<div class="palm--hidden"><?php the_excerpt(); ?><p></p></div>
Read More
<div class="social-icons-2">
<ul class="hl">
<li>Share:</li>
<li><a <a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t= <?php the_excerpt(); ?><?php the_title(); ?>"<i class="fa fa-facebook"></i></a></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-pinterest"></i></li>
</ul>
</div>
<?php
endwhile; endif;
?>
</div>
</article>
</div>
<div class="col-sm-6 news-post" style="background-color: #ffcccc" data-key="newsItem">
<article class="grid row">
<?php
$query = new WP_Query( array( 'post_type' => 'news', 'posts_per_page' => 1 ) );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
?>
<div data-ratio="1" class="grid__item grid__item_inline one-half">
<figure data-ratio="1">
<?php
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
$image = wp_get_attachment_image_src( $post_thumbnail_id, 'homepage-thumb' );
?>
<img width="640" height="640" class="img-responsive" src="<?php echo $image[0]; ?>" alt="" />
</figure>
</div>
<div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ffcccc" >
<h1>NEWS</h1>
<time class="timestamp"><?php the_date(); ?></time>
<h2 class="h4"><?php the_title(); ?></h2>
<div class="palm--hidden"><p><?php the_excerpt(); ?></p></div>
Read More
<div class="social-icons-2">
<ul class="hl">
<li>Share:</li>
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-pinterest"></i></li>
</ul>
</div>
</div>
<?php
endwhile; endif;
?>
</article>
</div>
<div class="col-sm-6 news-post" style="background-color: #ffffff" data-key="newsItem">
<article class="grid row">
<div data-ratio="1" class="grid__item one-half">
<figure data-ratio="1">
<!-- SnapWidget -->
<!-- SnapWidget -->
<!-- SnapWidget -->
<iframe src="http://snapwidget.com/sc/?u=aW5fc3BhY2VzfGlufDI4MHwzfDN8fG5vfDV8bm9uZXx8eWVzfG5v&ve=020914" title="Instagram Widget" class="snapwidget-widget" allowTransparency="true" frameborder="0" scrolling="no" style="border:none; overflow:hidden; width:295px; height:295px"></iframe>
</figure>
</div>
<div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed twitter-widget" style="background-color: #ffffff" >
<a class="twitter-timeline" data-dnt="true" href="sm2" data-widget-id="501148708545638400">Tweets by #In__Spaces</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
</article>
</div>
<div class="post-1410 post type-post status-publish format-standard has-post-thumbnail hentry category-news col-sm-6 news-post" style="background-color: #ffffcc" data-key="newsItem">
<article class="grid row">
<?php
$query = new WP_Query( array( 'post_type' => 'event', 'posts_per_page' => 1 ) );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
?>
<div data-ratio="1" class="grid__item grid__item_inline one-half">
<figure data-ratio="1">
<?php
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
$image = wp_get_attachment_image_src( $post_thumbnail_id, 'homepage-thumb' );
?>
<img width="640" height="640" class="img-responsive" src="<?php echo $image[0]; ?>" alt="" />
</figure>
</div>
<div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ffffcc" >
<h1>EVENTS</h1>
<time class="timestamp">August 22, 2014</time>
<h2 class="h4"><?php the_title(); ?></h2>
<div class="palm--hidden"><p><?php the_excerpt(); ?></p></div>
Read More
<div class="social-icons-2">
<ul class="hl">
<li>Share:</li>
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-pinterest"></i></li>
</ul>
</div>
</div>
<?php
endwhile; endif;
?>
</article>
</div>
<div class="big-link">
</div>
</div>
</div>
</div>
</div><!-- #main -->
<?php get_footer(); ?>
You need to use Open Graph Tags in the <head> section of your page.
Here's an example:
<meta property="og:title" content="<?=the_title();?>" />
<meta property="og:description" content="<?=the_excerpt();?>" />
<meta property="og:type" content="blog" />
<meta property="og:url" content="<?=the_permalink();?>" />
<meta property="og:site_name" content="YOUR_SITE_NAME" />
I have created a Blog list through wordpress custom page template and assigned the same by creating a blog page.
But I am wondering the loop is correct but its not displaying any result.
http://projects.dev2d.com/msleximus/blog/
What to do. My Code ....
<?php
/*
Template Name: Blog
*/
get_header(); ?>
<!-- #primary -->
<div role="main" class="main">
<section class="page-top">
<div class="container">
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li>Home <span class="divider">/</span></li>
<li class="active">
<?php wp_title(); ?>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="span12">
<h2> Blog </h2>
</div>
</div>
</div>
</section>
<div class="container">
<div class="row">
<div class="span9">
<?php
if ( is_page() ) {
$category = get_post_meta( $posts[0]->ID, 'category', true );
$cat = get_cat_ID( $category );
}
if ( $cat ) :
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$post_per_page = 4; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array (
'category__in' => array( $cat ),
'post_type'=> 'post',
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'ignore_sticky_posts' => $do_not_show_stickies
);
$temp = $wp_query; // assign original query to temp variable for later use
global $wp_query;
$wp_query = null;
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<div class="blog-posts">
<article <?php post_class() ?> id="post-<?php the_ID(); ?>class="post post-medium-image">
<div class="row">
<div class="span4">
<div class="post-image">
<div class="flexslider flexslider-center-mobile flexslider-simple" data-plugin-options='{"controlNav":false, "animation":"slide", "slideshow": false, "maxVisibleItems": 1}'>
<ul class="slides">
<li> <img class="img-rounded" src="<?php the_post_thumbnail('medium'); ?>" alt="featured image"></li>
</ul>
</div>
</div>
</div>
<div class="span5">
<div class="post-content">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a></h2>
<?php the_content( 'read more »' ); ?>
</div>
</div>
</div>
<div class="row">
<div class="span9">
<div class="post-meta"> <span><i class="icon-calendar"></i>
<?php the_time( 'F jS, Y' ) ?>
</span> <span><i class="icon-user"></i> By <a href="#">
<?php the_author() ?>
</a> </span> <span><i class="icon-tag"></i>
<?php the_tags( 'Tags: ', ', ', '<br />' ); ?>
,</span> <span><i class="icon-comments"></i>
<?php comments_popup_link( 'No Comments »', '1 Comment »', '% Comments »' ); ?>
Read more... </div>
</div>
</div>
</article>
<?php endwhile; ?>
<div class="pagination pagination-large pull-right">
<div class="alignleft">
<?php next_posts_link( '« Older Entries' ) ?>
</div>
<div class="alignright">
<?php previous_posts_link( 'Newer Entries »' ) ?>
</div>
</div>
</div>
</div>
<?php endif; // if ( $wp_query->have_posts() ) ?>
<?php $wp_query = $temp; //reset back to original query ?>
<div class="span3">
<aside class="sidebar">
<?php get_search_form(); ?>
<?php get_sidebar(); ?>
<div class="tabs">
<ul class="nav nav-tabs">
<li class="active"><i class="icon-star"></i> Popular</li>
<li>Recent</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="popularPosts">
<?php fanciedmedia_popular_posts(5); ?>
</div>
<div class="tab-pane" id="recentPosts">
</div>
</div>
</div>
<hr />
</aside>
</div>
<?php else : ?>
<div class="row">
<div class="span12">
<div class="post-content">
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
</div>
</div>
</div>
<?php endif; // if ( $cat ) ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Use this one and do let me know ..
<div class="container">
<div class="row">
<div class="span9">
<div class="blog-posts">
<?php query_posts('category_name = Category&showposts=10'); ?>
<?php while (have_posts()) : the_post() ?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>class="post post-medium-image">
<div class="row">
<div class="span4">
<div class="post-image">
<div class="flexslider flexslider-center-mobile flexslider-simple" data-plugin-options='{"controlNav":false, "animation":"slide", "slideshow": false, "maxVisibleItems": 1}'>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail('medium');
} ?>
</div>
</div>
</div>
<div class="span5">
<div class="post-content">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a></h2>
<?php the_excerpt(); ?>
Read more... </div>
</div>
</div>
<div class="row">
<div class="span9">
<div class="post-meta"> <span><i class="icon-calendar"></i>
<?php the_time( 'F jS, Y' ) ?>
</span> <span><i class="icon-user"></i> By <a href="#">
<?php the_author() ?>
</a> </span> <span><i class="icon-tag"></i>
<?php the_tags( 'Tags: ', ', ', '<br />' ); ?>
,</span> <span><i class="icon-comments"></i>
<?php comments_popup_link( 'No Comments »', '1 Comment »', '% Comments »' ); ?>
</div>
</div>
</div>
</article>
<?php endwhile; ?>
<?php global $wp_query; $total_pages = $wp_query->max_num_pages; if ( $total_pages > 1 ) { ?>
<div class="pagination pagination-large pull-right">
<div class="alignleft">
<div class="nav-next alignright">
<?php previous_posts_link( 'Newer posts' ); ?>
</div>
</div>
<div class="alignright">
<div class="nav-previous alignleft">
<?php next_posts_link( 'Older posts' ); ?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>