Q and A FAQ and Knowledge Base for WordPress
[Plugin: Q & A FAQ and Knowledge Base] Home page doesn't show all FAQs after sorting by rat (3 posts)

  1. boxcarpress
    Posted 3 years ago #

    We switched to sorting by rating, but this has the effect of removing many FAQs from our home page. Some FAQs had a postmeta 'votes_count' of 0, but many of the FAQs didn't have a postmeta for 'votes_count' at all. These entries were not created by the q-and-a plugin for all FAQs when I enabled ratings (as they should have been by the plugin).

    So, if you find yourself in this situation, you can run this SQL query to ensure that all records without a 'votes_count' postmeta value show up on your home page.

    insert into wp_postmeta
    select p.ID, 'votes_count',0
    from wp_posts p
    where post_type = 'qa_faqs'
    and p.ID not in
    (select p2.ID
    from wp_posts p2
    left outer join wp_postmeta m2 on m2.post_id = p2.ID
    where m2.meta_key = 'votes_count');


  2. Dalton Rooney
    Plugin Author

    Posted 3 years ago #

    Hi Boxcarpress,
    There is an upgrader script that is run if you are upgrading from a prior version of Q & A that looks like this:

    $args = array(
    		'post_type'     => 'qa_faqs',
    		'post_status'   => 'publish',
    		'posts_per_page' => -1
    	$qa_faqs = new WP_Query( $args );
    	while( $qa_faqs->have_posts() ): $qa_faqs->the_post();
    		global $post;
    		add_post_meta($post->ID, 'votes_count', '0', true);

    Can you think of any reason why this script wouldn't have run or added the necessary meta content? Were you using the previous version of the plugin or did you create your FAQs another way?


  3. boxcarpress
    Posted 3 years ago #

    Not quite sure about why this would have happened. Two things of note, we moved from the regular 1.0.5 q-and-a plugin to the q-and-a-plus plugin at around the same time. Also, I might suggest using php's version_compare() function, which might avoid some issues down the line (this has bitten me in the past, though I'm skeptical it was the problem here):

    '1.0.10' > '1.0.5'; // false
    version_compare( '1.0.10', '1.0.5', '>' ); //true

    We did not create FAQs any other way than with the previous version of q-and-a.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.