• Resolved Usce

    (@usce)


    Hi,

    Here is the situation. I am using WP Ulike plugin on my page https://www.dnevnadoza.org – it is working fine. Now I don’t know how to make page featured with top post’s, something like top 100 and that top 100 liked posts also be on my Top page stream followed by number of likes stored in WP Ulike plugin.

    Anybody has some kind of code or correction or something, it would be really helpfull. Thank you very much!!!

    Usce

    https://www.ads-software.com/plugins/wp-ulike/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Alimir

    (@alimir)

    Hello @usce
    You can use the wordpress query in your theme. (Please read the plugin FAQ document)

    Thread Starter Usce

    (@usce)

    Hi Alimir,

    I just read FAQ and I found a code for that but I don’t know how to integrate it with my page. How to make that top 100 liked be on my top 100 page?

    Do I need to put <?php
    $the_query = new WP_Query(array(
    ‘post_status’ =>’published’,
    ‘post_type’ =>’post’,
    ‘orderby’ => ‘meta_value_num’,
    ‘meta_key’ => ‘_liked’,
    ‘paged’ => (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1
    ));
    ?>
    in php. fucntions or??

    Thank you on help!

    Thread Starter Usce

    (@usce)

    I just put that code in my functions.php and nothing changed? So do i need it to modify or something?

    Plugin Author Alimir

    (@alimir)

    Thread Starter Usce

    (@usce)

    Ok i we read and I came to consclusion i can make multiple querys, but that will make my posts sorted by likes. Can I make it that on my main page homepage, be everything with normal loop, BUT that most liked post’s from my homepage be on my top page.

    Is that meanning that i need to make multiple loops and somehow apply another loop to my top100 page for example?

    Plugin Author Alimir

    (@alimir)

    Hi @usce
    Try these codes in your function.php file:

    add_filter('posts_join', 'wp_ulike_new_join' );
    function wp_ulike_new_join($join){
    	if(is_home()){
    		global $wpdb;
    		$join .= "	LEFT JOIN (
    					SELECT *
    					FROM ".$wpdb->prefix."postmeta
    					WHERE meta_key =  '_liked' ) AS metasort
    					ON ".$wpdb->prefix."posts.ID = metasort.post_id";
    	}
    	return ($join);
    }
    
    add_filter('posts_orderby', 'wp_ulike_new_order' );
    function wp_ulike_new_order( $orderby ){
    	if(is_home()){
    		global $wpdb;
    		$orderby = "metasort.meta_value DESC";
    	}
     	return $orderby;
    }

    hi Alimir, I readed the FAQ, and it worked with your last code in this thread (I put it in functions.php) but then I have a problem:

    I have a widget with the “Latest posts” ordered by date, but when I use your code the widget posts are ordered by likes/votes too, not by date.

    So my question is: where I have to put the code to affect only the home page and not the widgets or other sections of the blog.

    I tried on content.php but cant make it work. I would appreciate your help,and ofc I will buy the premium version or donate when its avaliable. This is the best rating plugin I found after hours trying lots of other plugins.

    Thanks!

    hey finally it worked for me, just made a new page template and used the FAQ code:

    <?php
        $the_query = new WP_Query(array(
        'post_status' =>'published',
        'post_type' =>'post',
        'orderby' => 'meta_value_num',
        'meta_key' => '_liked',
        'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
        ));
    ?>

    By the way, theres a tiny typo in the code: published should be publish in the query. ??

    Plugin Author Alimir

    (@alimir)

    Hi @hicks78

    glad to hear the problem is fixed ??
    Thanks for your feedback. I’ll fix this typo in the next update.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to make top posts page, using most liked posts with ULIKE’ is closed to new replies.