Home Forums WTI Like Post PRO Is the post meta available only for the liked/disliked posts?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #659
    leonardopenna
    Participant

    Hello,

    I’m trying to sort all posts by the post meta _wti_like_count. The problem is that only posts that received a vote (like or dislike) are being listed. It looks like items with 0 votes are not added to the DB and don’t have post meta. Is there a workaround for this issue?

    Thanks!

    #660
    Webtechideas
    Keymaster

    Logically it’s correct not to include all. Since you want to sort them by like/unlike counts, they must have received votes first. It doesn’t make sense to include those which don’t have any counts.

    You can try by hitting the “Update Like Meta” button on the plugin admin settings page. It assigns/updates like meta data for those who do not have this entry. If this doesn’t work for you, can you please share the code you are trying with?

    #661
    leonardopenna
    Participant

    Hello!

    For my case scenario, it’s important to list the posts with 0 votes, putting them at the end of the list.

    I tried to hit the “Update Like Meta” button, without results. But even if it had worked, it would be a manual workaround. I need to automatically generate metadata (_wti_like_count) for the posts when the user creates them.

    Right now, I’m using WTI Like Post PRO together with Search & Filter Pro. I just need to choose the post meta that will be used as a sorting parameter.

    Maybe I can trigger the post meta creation when saving a post? I already use a function to customize a few things:

    add_action(‘acf/save_post’, ‘save_practice’, 20);
    function save_practice($post_id) {
    $post_type = get_post_type($post_id);
    if ($post_type != ‘practice’) {
    return;
    }

    }

    Thanks again!

    #662
    Webtechideas
    Keymaster

    The code is already there to automatically set like, unlike, total values to 0 on creating a post. This works well with the default process of wordpress post creation.

    If it’s a different approach for you, then make sure that native wordpress function us used for post creation which will trigger the hook used by our plugin.

    #663
    leonardopenna
    Participant

    Can I trigger the hook manually (in my code)? Thanks

    #664
    Webtechideas
    Keymaster

    This is how our custom function is attached to the wordpress hook

    add_action('save_post', 'WtiLikePostSaveData');

    Click here for more details on this hook.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘WTI Like Post PRO’ is closed to new topics and replies.