WordPress.org

Forums

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
    Member
    Posted 2 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
    (post_id,meta_key,meta_value)
    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');

    http://wordpress.org/extend/plugins/q-and-a/

  2. Dalton Rooney
    Member
    Plugin Author

    Posted 2 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);
    	endwhile;

    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?

    Dalton

  3. boxcarpress
    Member
    Posted 2 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 1.0.5.1 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

  • Q and A FAQ and Knowledge Base for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.