Somewhat new to Wordpress and PHP and trying to work though this issue. I have a page (http://www.moderateindividual.com.php53-13.dfw1-1.websitetestlink.com/) and twards the bottom you can see a section with 6 images, I need those to be pulled in from a custom post type with a custom taxonomy. What I have now its just pulling in one post over and over, how would I make this pull in the 6 latest post in that category?
Here is my code I have so far
<?php
//Define your custom post type name in the arguments
$args = array(
'post_type' => 'news',
'tax_query' => array(
array(
'taxonomy' => 'news_category',
'field' => 'id',
'terms' => '47',
),
),
);
//Define the loop based on arguments
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="st_views">
<div class="tab-1 st_view">
<div class="st_view_inner">
<div class="row cat-title">
<p><span>As To Them Shall Seem Most Likely…</span> / Nullam quis dolor interdum erat dapibus aliquam. View all</p>
</div>
<div class="row top-stories">
<div class="small-12 medium-8 large-8 columns main-news img-wrap"> <?php the_post_thumbnail('home-featured-thumb'); ?>
<div class="story-title">
<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>" />Read More</a></p>
</div>
</div>
<!--End Large-8 Columns-->
<div class="large-4 small-12 medium-4 columns">
<div class="row news-top img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>
<div class="story-title-sub">
<a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2></a>
</div>
</div>
<div class="row news-bottom img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>
<div class="story-title-sub">
<a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2>
</div>
</div>
</div>
<!--End Large-4 Columns-->
</div>
<div class="row bottom-stories">
<div class="large-4 medium-4 small-12 columns img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>
<div class="story-title-sub">
<a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2>
</div>
</div>
<!--End Large-4 Columns-->
<div class="large-4 medium-4 small-12 columns img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>
<div class="story-title-sub">
<a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2></a>
</div>
</div>
<!--End Large-4 Columns-->
<div class="large-4 medium-4 small-12 columns img-wrap"> <a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail('home-thumb'); ?></a>
<div class="story-title-sub">
<a href="<?php the_permalink(); ?>" /><h2><?php the_title(); ?></h2></a>
</div>
</div>
<!--End Large-4 Columns-->
</div>
<!--End Row-->
</div>
<!--End st view inner-->
</div>
<?php endwhile;?>
<!--End tab 1 st view-->
The code above was me just searching the google for something that might work.
Any help or advice would be great.
you just have to make 2 loops and use the offset parameter
<div class="st_views">
<div class="tab-1 st_view">
<div class="st_view_inner">
<?php
//Define your custom post type name in the arguments
$args = array(
'post_type' => 'news',
'tax_query' => array(
array(
'taxonomy' => 'news_category',
'field' => 'id',
'terms' => '47',
),
),
'posts_per_page' => 3
);
//Define the loop based on arguments
$loop = new WP_Query( $args ); if ( $loop->have_posts() ):?>
<div class="row cat-title">
<p><span>As To Them Shall Seem Most Likely…</span> / Nullam quis dolor interdum erat dapibus aliquam. View all</p>
</div>
<div class="row top-stories">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if( $loop->current_post == 0 ){?>
<div class="small-12 medium-8 large-8 columns main-news img-wrap"> <?php the_post_thumbnail('home-featured-thumb'); ?>
<div class="story-title">
<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?>Read More</p>
</div>
</div>
<!--End Large-8 Columns-->
<?php } elseif( $loop->current_post == 1 ){?>
<div class="large-4 small-12 medium-4 columns">
<div class="row news-top img-wrap"> <?php the_post_thumbnail('home-thumb'); ?>
<div class="story-title-sub">
<h2><?php the_title(); ?></h2>
</div>
</div>
<?php } elseif( $loop->current_post == 2 ){?>
<div class="row news-bottom img-wrap"> <?php the_post_thumbnail('home-thumb'); ?>
<div class="story-title-sub">
<h2><?php the_title(); ?></h2>
</div>
</div>
</div>
<!--End Large-4 Columns-->
<?php }?>
<?php endwhile;?>
</div>
<?php endif; //End Top Stories?>
<?php
//Define your custom post type name in the arguments
$args2 = array(
'post_type' => 'news',
'tax_query' => array(
array(
'taxonomy' => 'news_category',
'field' => 'id',
'terms' => '47',
),
),
'posts_per_page' => 3,
'offset' => -3
);
//Define the loop based on arguments
$loop2 = new WP_Query( $args2 ); if ( $loop2->have_posts() ):?>
<div class="row bottom-stories">
<?php while ( $loop2->have_posts() ) : $loop2->the_post(); ?>
<div class="large-4 medium-4 small-12 columns img-wrap"> <?php the_post_thumbnail('home-thumb'); ?>
<div class="story-title-sub">
<h2><?php the_title(); ?></h2>
</div>
</div>
<!--End Large-4 Columns-->
<?php endwhile; ?>
</div>
<!--End Bottom Row-->
<?php endif;?>
</div>
<!--End tab 1 st view inner-->
</div>
<!--End tab 1 st view-->
</div>
<!--End st view-->
Related
I'm messing around with my code. My goal is to display 4 custom post type on the homepage in the HTML layout I've created. Here's my code. Actually I can get the href but I can't loop the code not even achieve my scope.
<div class="roundedframe ">
<div class="container-fluid">
<div class="row">
<div class="col-lg-4 col-sm-6">
<a class="portfolio-box" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<div class="portfolio-box-caption">
<div class="portfolio-box-caption-content">
<div class="project-category text-faded">
Category
</div>
<div style="background-image: url('<?php the_post_thumbnail_url(); ?>');">
<div class="project-name"> <?php // WP_Query arguments
$args = array(
'name' => 'case-studies',
'nopaging' => true,
'posts_per_page' => '4',
);
// The Query
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
?>
Project Name
</div>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
Assuming the post type you want is case-studies you should name the key post_type and not name. You also have to place the column inside the loop and close it afterwards. You also missed a </div> tag.
<?php $query = new WP_Query( [
'post_type' => 'case-studies',
'nopaging' => true,
'posts_per_page' => '4',
] ); ?>
<?php if ( $query->have_posts() ) : ?>
<div class="roundedframe ">
<div class="container-fluid">
<div class="row">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-lg-4 col-sm-6">
<a class="portfolio-box" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<div class="portfolio-box-caption">
<div class="portfolio-box-caption-content">
<div class="project-category text-faded">
Category
</div>
<div style="background-image: url('<?php the_post_thumbnail_url(); ?>');">
<div class="project-name">
<h2><?php the_title(); ?></h2>
</div>
</div>
</div>
</div>
</a>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
You should put your code in the looping area. What i can see, you missed the endwhile also.
<div class="roundedframe ">
<div class="container-fluid">
<div class="row">
<?php // WP_Query arguments
$args = array(
'name' => 'case-studies',
'nopaging' => true,
'posts_per_page' => '4'
);
// The Query
$query = new WP_Query($args);
while ($query->have_posts()):
$query->the_post(); ?>
<div class="col-lg-4 col-sm-6">
<a class="portfolio-box" href="<?php
get_the_permalink();
?>" title="<?php
get_the_title();
?>">
<div class="project-category text-faded">
Category
</div>
<div style="background-image: url('<?php
the_post_thumbnail_url();
?>');">
<div class="project-name">
Project Name
</div>
</div>
</a>
</div>
<?php
endwhile;
?>
</div>
</div>
</div><!--.roundedframe-->
Try this and let me know. It may help you. Before that you should learn about wp_query
https://codex.wordpress.org/Class_Reference/WP_Query
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 am trying to make a slider cycle through the custom posts in Wordpress, displaying 4 at a time.
I would like it to cycle through the posts and just loop back to the first one when it has reached the last post.
My code is:
<div id="myCarousel" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item active">
<div class="row">
<?php
$args = array(
'posts_per_page' => '4',
'post_type' => 'dogs',
);
$myDogs = new WP_Query( $args ); ?>
<?php while ( $myDogs->have_posts() ) : $myDogs->the_post();?>
<div id="sl-cont" class="col-sm-12 col-md-3 col-lg-3">
<div class="well">
<?php the_post_thumbnail('slider-size'); ?>
<div class="dog-caption">
<p><span class="title"><?php the_title(); ?></span><br/>
<?php the_excerpt(); ?><br/>
Read more >> </p>
</div>
</div><!--end of well-->
</div><!--end of container-->
<?php endwhile;
wp_reset_postdata();?>
</div>
<!--/row-->
</div>
<!--/item-->
<div class="item">
<div class="row">
<?php
$args = array(
'posts_per_page' => '4',
'post_type' => 'dogs',
'offset' => 1
);
$myDogs = new WP_Query( $args ); ?>
<?php while ( $myDogs->have_posts() ) : $myDogs->the_post();?>
<div id="sl-cont" class="col-sm-12 col-md-3 col-lg-3">
<div class="well">
<?php the_post_thumbnail('slider-size'); ?>
<div class="dog-caption">
<p><span class="title"><?php the_title(); ?></span><br/>
<?php the_excerpt(); ?><br/>
Read more >> </p>
</div>
</div><!--end of well-->
</div><!--end of container-->
<?php endwhile;
wp_reset_postdata();?>
</div>
<!--/row-->
</div>
<!--/item-->
</div> <!--/carousel-inner-->
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><img src="<?php bloginfo('template_directory'); ?>/img/left-paw.png"> </a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><img src="<?php bloginfo('template_directory'); ?>/img/right-paw.png"></a>
`
Can anyone help?
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>