Home › Forums › WTI Like Post PRO › Page with all posts
- This topic has 5 replies, 2 voices, and was last updated 9 years, 11 months ago by Webtechideas.
-
AuthorPosts
-
November 18, 2014 at 5:47 pm #242kaioianParticipant
Hello, I created a page with all posts, shown by likes. But the posts with zero like are not shown. Can you help me. I want to show all posts even those with zero likes. Thanks. This is the page template I use.
<?php
/**
* Template Name: Most Liked Posts
*
* Description: Twenty Twelve loves the no-sidebar look as much as
* you do. Use this page template to remove the sidebar from any page.
*
* Tip: to remove the sidebar from all posts and pages simply remove
* any active widgets from the Main Sidebar area, and the sidebar will
* disappear everywhere.
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/get_header(); ?>
<div id=”primary” class=”site-content”>
<div id=”content” role=”main”>
<?php
// Get the last voted time based on a week
$last_voted_time = GetWtiLastDate(‘6m’);// Query to get all posts sorted by like count after a specific date
$query = query_posts(
array(
‘post_type’ => ‘post’,
‘cat’ => ‘-20’,
‘posts_per_page’ => 300,
‘meta_key’ => ‘_wti_like_count’,
‘orderby’ => ‘meta_value_num’,
‘order’ => ‘DESC’,
‘meta_query’ => array(
array(
‘key’ => ‘_wti_last_voted_time’,
‘value’ => $last_voted_time,
‘type’ => ‘DATETIME’,
‘compare’ => ‘>=’
)
)
)
);if ( have_posts() ) :
?>
<?php while ( have_posts() ) : the_post(); ?>
<article style=”border: 1px solid rgba(25, 100, 164, 1); padding: 9px; margin:25px; padding-bottom: 35px;”>
<header class=”entry-header”>
<div class=”numbering” style=”width:80px; height:150px; background-color:rgba(25, 100, 164, 1);line-height: 143px;”> <p style=”text-align: center;
color: white; font-size: 40px”>
<?php /* First method to create array. */
$numbers = array( $number = $number + 1 );
foreach( $numbers as $value )
{
echo “$value”;
}
?></p>
</div>
<div class=”imagekk” style=”width:150px; height:150px; margin-top: -150px; margin-left: 80px;”><?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail(‘thumbnail’); } ?></div><div class=”top_excerpt_name” style=””>
<h1 class=”entry-title”>“><?php the_title(); ?> <?php GetWtiLikePost()?></h1>
<div class=”entry-content”><?php
$my_excerpt = get_the_excerpt();
if ( $my_excerpt != ” ) {
// Some string manipulation performed
}
echo $my_excerpt; // Outputs the processed value to the page
?></div>
</div></header>
</article>
<?php endwhile; ?>
<?php
else :
?>
<article>
<div class=”entry-content”>
<p><?php _e( ‘Nothing Found’, ‘wti-like-post’ ); ?></p>
</div>
</article>
<?php
endif;// Reset Query
wp_reset_query();
?></div><!– #content –>
</div><!– #primary –><?php get_footer(); ?>
November 21, 2014 at 7:06 pm #243WebtechideasKeymasterI assume you have not made much modifications to our script. The script picks the posts which have like count as meta data. So if a post does not have this meta data, then it won’t be shown. If you were using the lite version prior to using this pro version, then it’s likely that some posts might have missed out the meta data. Those posts which have recorded fresh votings will surely have the meta data and show up.
You will find a button
Update Like Meta
on the plugin configuration page. Use this button to update the like meta data. This will result in having meta data for all posts and the posts will show up with the script you are using.Note:
– Since this will modify the post data, please have a database back up before proceeding.Thanks
November 21, 2014 at 8:23 pm #244kaioianParticipantI’m using the pro version of the plugin. So to show posts which have no votes yet, I have to use the button “Update Like Meta”? Is this mean every time when I post a new post I’ll have to use the button “Update Like Meta”? Is there another way to show posts in a page which doesn’t have any votes and people to vote for them.
Thanks!
November 23, 2014 at 2:01 pm #245WebtechideasKeymasterThis should work for you and you do not need to use this each time you add a post. Using
query_posts
orWP_Query
is the better approach. Another way will be using raw queries. If you need that, then we will need some time to prepare that. Please confirm whether the existing approach works for you or not. Thanks..November 26, 2014 at 5:29 pm #246kaioianParticipantWhat is raw queries? How to use
query_posts
orWP_Query
? I should use it in the page template?December 2, 2014 at 4:41 am #247WebtechideasKeymasterBy raw queries I mean using simple queries without using wordpress specific functions as you mentioned.
-
AuthorPosts
- The forum ‘WTI Like Post PRO’ is closed to new topics and replies.