Question
-
Is it possible to have a rating with the most thumb up, but like normal blog post list ( feature image etc…)?
thx
-
Yes it’s posible.
If you check the thumbs-rating.php source code you’ll find this function thumbs_rating_top_func()
That functions does exactly what you need to but it does not print the blog content or image.
I’d be something like:
$args = array ( 'post_type' => any, // or post or page 'post_status' => 'publish', 'cat' => '', 'pagination' => false, 'posts_per_page' => 10, 'cache_results' => true, 'meta_key' => _thumbs_rating_up, // or _thumbs_rating_down 'orderby' => 'meta_value' ); $thumbs_ratings_top_query = new WP_Query($args); if($thumbs_ratings_top_query->have_posts()) : $return .= '<ol class="thumbs-rating-top-list">'; while($thumbs_ratings_top_query->have_posts()){ the_title(); the_content(); } }
Cheers.
Ok so what i have to do?
i have to place the shortocde on a page [thumbs_rating_top posts_per_page=”10″ post_type=”page” show_votes=”no”]
and i have to modify the code?
thx
The code on my reply has to go inside your theme, wherever you want to show the posts. Theme file means index.php or archive.php, etc.
The code can not be pasted inside a post, page or widget. That’s what the shortcode is for
[thumbs_rating_top posts_per_page="10" post_type="page" show_votes="no"]
However the shortcode won’t show the post content or image.
ok i understand
What do you advice me, i create a blog like 9gag, the user can add post with just a image, in botom the post the user can vote with your plugin
Si i want make page ” top” with a rating from your plugin
So i paste your code into which page php you think?
Thx a lot ??
Alright, I’d create a Page Template called “top positve posts”
https://codex.www.ads-software.com/Page_Templates
Then you assign this page template to a normal Page.
Inside the page template (php) you paste the code and customize it to fit your needs.
Maybe there’s a more complete plugin out there that does everything you need.
i try but i have a white page
I do :
I have a page.php in my theme with this code :
<?php get_header(); ?>
<?php nectar_page_header($post->ID); ?>
<div class=”container main-content”>
<div class=”row”>
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div><!–/row–>
</div><!–/container–>
<?php get_footer(); ?>
I copy this page and rename “top positif post”
And after i have to copy your code and insert inside?
sorry ??
1) Follow the Codex documentation on how to create a Custom Page Template.
2) Once it’s working try pasting my code inside.
i create a custom page template.php with this code inside
<?php
/*
Template Name: My Custom Page
*/get_header(); ?>
<?php nectar_page_header($post->ID); ?>
<div class=”container main-content”>
<div class=”row”>
<div id=”post-area” class=”col span_9″>
<?phpif(have_posts()) : while(have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div><!–/span_9–>
<div id=”sidebar” class=”col span_3 col_last”>
<?php get_sidebar(); ?>
</div><!–/span_9–></div><!–/row–>
</div><!–/container–>
<?php get_footer(); ?>
But i dont know where i have to add your code inside, i try but doesnt work :/
And also i added the shortcode on the same page (frontend) [thumbs_rating_top posts_per_page=”10″ post_type=”post” show_votes=”no”]
thx
Hey, you almost got it.
I’ve built a full working example with your code. Copy and paste this inside your custom page:
Notice I’ve removed this line:
<?php nectar_page_header($post->ID); ?>
I’m not sure if you needed. If you do, just put it back:
<?php /* Template Name: My Custom Page */ get_header(); ?> <div class="container main-content"> <div class="row"> <div id="post-area" class="col span_9"> <?php $args = array ( 'post_type' => any, // or post or page 'post_status' => 'publish', 'cat' => '', 'pagination' => false, 'posts_per_page' => 10, 'cache_results' => true, 'meta_key' => _thumbs_rating_up, // or _thumbs_rating_down 'orderby' => 'meta_value' ); $thumbs_ratings_top_query = new WP_Query($args); if($thumbs_ratings_top_query->have_posts()){ while($thumbs_ratings_top_query->have_posts()){ $thumbs_ratings_top_query->the_post(); echo "<h2>" . get_the_title() . "</h2>"; echo "<div>" . get_the_content() . "</div>"; } } wp_reset_postdata(); ?> </div><!--/span_9--> <div id="sidebar" class="col span_3 col_last"> <?php get_sidebar(); ?> </div><!--/span_9--> </div><!--/row--> </div><!--/container--> <?php get_footer(); ?>
I’m guessing your theme do not use the function get_the_content() to print the images.
Try to look at your index.php file and copy the method. Replace the part on the custom page that says:
echo "<div>" . get_the_content() . "</div>";
this one is my index.php
<?php get_header(); ?>
<?php nectar_page_header($post->ID); ?>
<div class=”container main-content”>
<?php if(!is_home()) { ?>
<div class=”row”>
<div class=”col span_12 section-title blog-title”>
<h1><?php wp_title(“”,true); ?></h1>
</div>
</div>
<?php } ?><div class=”row”>
<div id=”post-area” class=”col span_9″>
<?phpif(have_posts()) : while(have_posts()) : the_post(); ?>
<?php get_template_part( ‘includes/post-templates/entry’, get_post_format() ); ?>
<?php endwhile; endif; ?>
<?php nectar_pagination(); ?>
</div><!–/span_9–>
<div id=”sidebar” class=”col span_3 col_last”>
<?php get_sidebar(); ?>
</div><!–/span_3–></div><!–/row–>
</div><!–/container–>
<?php get_footer(); ?>
Alright, then you need the content from this file: includes/post-templates/entry.php
ok its :
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<div class=”post-content”>
<?php if( !is_single() ) { ?>
<?php
$extra_class = ”;
if (!has_post_thumbnail()) $extra_class = ‘no-img’;
?><div class=”post-meta <?php echo $extra_class; ?>”>
<div class=”date”>
<span class=”month”><?php the_time(‘M’); ?></span>
<span class=”day”><?php the_time(‘d’); ?></span>
<?php $options = get_option(‘salient’);
if(!empty($options[‘display_full_date’]) && $options[‘display_full_date’] == 1)
echo ‘<span class=”year”>’. get_the_time(‘Y’) .'</span>’;
?></div><!–/date–>
<div class=”nectar-love-wrap”>
<?php if( function_exists(‘nectar_love’) ) nectar_love(); ?>
</div><!–/nectar-love-wrap–></div><!–/post-meta–>
<?php } ?>
<div class=”content-inner”>
<?php if ( has_post_thumbnail() ) {
if( !is_single() ) { echo ‘‘; }
echo get_the_post_thumbnail($post->ID, ‘full’, array(‘title’ => ”));
if( !is_single() ) { echo’‘; }
} ?>
<?php if( !is_single() ) { ?>
<div class=”post-header”>
<h2 class=”title”><?php if( !is_single() ) { ?> “><?php } ?><?php the_title(); ?><?php if( !is_single() ) {?> <?php } ?></h2>
<?php echo __(‘Posted by’, NECTAR_THEME_NAME); ?> <?php the_author_posts_link(); ?> | <?php the_category(‘, ‘); ?> | “>
<?php comments_number( __(‘No Comments’, NECTAR_THEME_NAME), __(‘One Comment ‘, NECTAR_THEME_NAME), __(‘% Comments’, NECTAR_THEME_NAME) ); ?>
</div><!–/post-header–>
<?php } ?><?php the_content(‘<span class=”continue-reading”>’. __(“Read More”, NECTAR_THEME_NAME) . ‘</span>’); ?>
<?php $options = get_option(‘salient’);
if( $options[‘display_tags’] == true ){if( is_single() && has_tag() ) {
echo ‘<div class=”post-tags”><h4>Tags: </h4>’;
the_tags(”,”,”);
echo ‘<div class=”clear”></div></div> ‘;}
}
?></div><!–/content-inner–>
</div><!–/post-content–>
</article><!–/article–>
ok its :
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<div class=”post-content”>
<?php if( !is_single() ) { ?>
<?php
$extra_class = ”;
if (!has_post_thumbnail()) $extra_class = ‘no-img’;
?><div class=”post-meta <?php echo $extra_class; ?>”>
<div class=”date”>
<span class=”month”><?php the_time(‘M’); ?></span>
<span class=”day”><?php the_time(‘d’); ?></span>
<?php $options = get_option(‘salient’);
if(!empty($options[‘display_full_date’]) && $options[‘display_full_date’] == 1)
echo ‘<span class=”year”>’. get_the_time(‘Y’) .'</span>’;
?></div><!–/date–>
<div class=”nectar-love-wrap”>
<?php if( function_exists(‘nectar_love’) ) nectar_love(); ?>
</div><!–/nectar-love-wrap–></div><!–/post-meta–>
<?php } ?>
<div class=”content-inner”>
<?php if ( has_post_thumbnail() ) {
if( !is_single() ) { echo ‘‘; }
echo get_the_post_thumbnail($post->ID, ‘full’, array(‘title’ => ”));
if( !is_single() ) { echo’‘; }
} ?>
<?php if( !is_single() ) { ?>
<div class=”post-header”>
<h2 class=”title”><?php if( !is_single() ) { ?> “><?php } ?><?php the_title(); ?><?php if( !is_single() ) {?> <?php } ?></h2>
<?php echo __(‘Posted by’, NECTAR_THEME_NAME); ?> <?php the_author_posts_link(); ?> | <?php the_category(‘, ‘); ?> | “>
<?php comments_number( __(‘No Comments’, NECTAR_THEME_NAME), __(‘One Comment ‘, NECTAR_THEME_NAME), __(‘% Comments’, NECTAR_THEME_NAME) ); ?>
</div><!–/post-header–>
<?php } ?><?php the_content(‘<span class=”continue-reading”>’. __(“Read More”, NECTAR_THEME_NAME) . ‘</span>’); ?>
<?php $options = get_option(‘salient’);
if( $options[‘display_tags’] == true ){if( is_single() && has_tag() ) {
echo ‘<div class=”post-tags”><h4>Tags: </h4>’;
the_tags(”,”,”);
echo ‘<div class=”clear”></div></div> ‘;}
}
?></div><!–/content-inner–>
</div><!–/post-content–>
</article><!–/article–>
- The topic ‘Question’ is closed to new replies.