Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • oh just created a new thread about this. well yeah I got the same problem, so it would be great if you could fix it.

    Thread Starter onz123

    (@onz123)

    When I used orderby=meta_value_num, it happened that some posts were displayed more than one time. So for example I went through the pagination, and 1 post appeared at page 2 and then again at page 4. I don’t know any other people who had this happening – really strange. It might be my website that has 700+ posts. Anyway, with orderby=meta_value and the values with leading zeros it worked.

    Hey I’m really trying to get this working: I want that when I click on the recommendation button in the loop, that at the same time it opens the selected post. I managed to have it open another URL with JavaScript onClick: `function open_win()
    {
    window.open(“https://url.com”)
    }`
    but this won’t work with window.open(<?php the_permalink(); ?>)

    You have any idea how to do this?

    Thread Starter onz123

    (@onz123)

    Well I just changed the part with update_post_meta to write the value with leading zeros to the database.

    $recommended++;
    $myfblikes = sprintf("%04s", $recommended);
    update_post_meta($post_id, '_recommended', $myfblikes);
    setcookie('dot_irecommendthis_'. $post_id, time(), time()+3600*24*365,'/');

    Then I changed the output to remove the leading zeros again. So that you don’t have “0001 People recommend this post”
    $output = '<span class="dot-irecommendthis-count">'. ltrim($recommended, '0') .'</span> <span class="dot-irecommendthis-suffix">'. $suffix .'</span>';

    To sort by the meta_value I simply use this:

    <?php
      query_posts('&orderby=meta_value&meta_key=_recommended&paged='.$paged.'');
    
    if (have_posts()): while (have_posts()) : the_post(); ?>

    Hey do you know how I can have a URL opened at the same time when the vote is done? I tried by replacing the “#” in this line with the URL I want to open but it won’t work.

    $dot_irt_html = '<a href="#" class="'. $class .'" id="dot-irecommendthis-'. $post_ID .'" title="'. $title .'">;'
    return $output;

    Thread Starter onz123

    (@onz123)

    Hey, I did that and it works fine. $mylikes = sprintf("%04s", $recommended); and ltrim($recommended, '0') – thanks

    Yes, I could just use the meta_value+0, but that does the same thing as meta_value_num. And I don’t know why, but the meta_value_num or meta_value+0 always creates some duplicate posts on my website and messes up the post order. The normal orderby=meta_value however works fine.

Viewing 4 replies - 1 through 4 (of 4 total)