Forum Replies Created

Viewing 15 replies - 16 through 30 (of 53 total)
  • Forum: Plugins
    In reply to: Paginate WordPress Query?
    Thread Starter Damien

    (@takster)

    Solved everything except getting pagination working with my custom query, not sure how '$wp_query->query('showposts=5'.'&paged='.$paged); fits in here.

    My working loop, without pagination. Any working tips on fitting pagination into my loop here and I owe you a beer or two.

    <?php global $wpdb;
    $query_sql = "SELECT like_pid FROM " . $wpdb->prefix ."likes_count ORDER BY like_count DESC LIMIT 6 OFFSET 0";
    $query_result = $wpdb->get_col( $wpdb->prepare ($query_sql, OBJECT));
    if ($query_result) {
    foreach ($query_result as $post_id) {
    $post = &get_post( $post_id );
    setup_postdata($post); ?>
    
    <?php $count++;
    if ($count%2== 0) : ?>
    
    <-- do the loop, count out two articles -->
    
    <?php else : ?>
    
    <-- do something after every two articles -->
    
    <?php endif;?>
    
    <?php } ?>
    <?php } ?> //ugly but works
    Thread Starter Damien

    (@takster)

    Seems easy enough, will look into this. Thanks for the info.

    Thread Starter Damien

    (@takster)

    License? A licence sounds like more paperwork :/
    f**k that ??

    I take it you mean what the theme’s released under? I was just planning on giving it away free…

    Thread Starter Damien

    (@takster)

    Anyone?

    Thread Starter Damien

    (@takster)

    solved with

    class Walker_xenpress extends Walker_Nav_Menu {
    function start_el(&$output, $item, $depth, $args) {
    global $wp_query;
    $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    $class_names = $value = '';
    $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    $classes[] = 'menu-item-' . $item->ID;
    $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
    $class_names = ' class="' . esc_attr( $class_names ) . '"';
    $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
    $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
    $output .= $indent . '<li' . $id . $value . $class_names .'>';
    $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
    $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
    $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
    $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
    $item_output = $args->before;
    $item_output .= '<a class="navLink"'. $attributes .'>';
    $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
    $item_output .= '</a>';
    $item_output .= $args->after;
    $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
    	}

    for now

    Thread Starter Damien

    (@takster)

    It stores the user ID of the member who voted so I can pull an array of user avatars or names that like the post, not just “3 people like this”.
    It could be made to work with guests but I never designed it that way.

    What sort of weird tags did you find btw in the other like plugin?

    coming soon wp-liked

    Forum: Plugins
    In reply to: Vote Each Post

    another nice one in the works here ??
    https://tak79.com/wp-liked-plugin/

    Thread Starter Damien

    (@takster)

    Thanks mate, got it ??

    $query_sql = "SELECT like_pid FROM " . $wpdb->prefix . "likes_count ORDER BY like_count DESC";

    Thread Starter Damien

    (@takster)

    "SELECT like_count FROM" . $wpdb->prefix . "likes_count ORDER BY like_count ASC LIMIT %d",

    works in phpmyadmin exactly as planned but breaks in wordpress, shows blank. :/

    Thread Starter Damien

    (@takster)

    <?php
    $liked = $wpdb->get_var($wpdb->prepare("SELECT COUNT(like_uid) FROM " . $wpdb->prefix .  "likes WHERE like_uid = %d", $post->post_author) );
    echo $liked."";
    ?>

    got it ??

    Thread Starter Damien

    (@takster)

    Thanks blepoxp, I’m trying to implement it, without much luck.

    <?php
    $liked = $wpdb->get_var($wpdb->prepare("SELECT COUNT(like_uid) FROM " . $wpdb->prefix .  "likes") );
    echo $liked."";
    ?>

    returns ‘9’ or the total count, so trying to narrow it down with something like

    <?php
    $liked = $wpdb->get_var($wpdb->prepare("SELECT COUNT(like_uid) FROM " . $wpdb->prefix .  "likes WHERE post_author = %d", $post->post_author) );
    echo $liked."";
    ?>

    I was hoping would restrict it to only counting the ID of that page’s author. Just returning a blank with the above. Will keep trying anyways.

    Thread Starter Damien

    (@takster)

    yes I cant get the ID working.

    Thread Starter Damien

    (@takster)

    Thanks, I have working

    <?php $liked = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(like_uid) FROM " . $wpdb->prefix .  "likes WHERE uid = %d", $uid) );
    echo $liked.""; ?>

    and it shows the rows total number of likes, but as you can see here
    https://img175.imageshack.us/img175/6621/captureho.png

    I have like_uid containing the user ID of the author, so I’m trying to get WHERE uid = %d”, $uid to only show the count total for the article author only, either on single.php or author.php.

    It’s almost like having “John likes 5 other posts” in his article rather then count them all. I cant seem to work it out .:/

Viewing 15 replies - 16 through 30 (of 53 total)