Search in Answers not possible?!

http://sup.pe/fragen/
Just figured out that the search does not cover any answers. That is really disappointing as it would help a lot to find the right info. Any chance to change that?
Thanks and cheers, Alex

  • aecnu
    • WP Unicorn

    Greetings Alex,

    Thank you for this great question and a significant item to bring up.

    I just visited the site and it appears that one must pay to see the answer?

    When I click on the question it bring me to a pay page or something to that effect?

    Please advise.

    Cheers, Joe

  • aecnu
    • WP Unicorn

    Greetings Alex,

    After a considerable amount of time I did figure out how to log in to your site.

    I have no way to figure out if the WordPress default search is actually searching through answers.

    Correction: After posting an answer I used the search facility included with the Questions and Answers plugin and could not pull up my answer in a search.

    Before I make any announcement that it indeed does not search through the answers, I will see if I can get the lead developer in here with his invaluable insight and advice.

    Though this may take a bit longer then a normal ticket, I will try to get him
    in here asap.

    Cheers, Joe

  • Hakan
    • The Incredible Smush

    Hi Alex,

    As being a custom post type, answers are excluded from search by default.

    I am not sure about the reasoning for that, but it is a choice by Wordpress developers, not by ours.

    In the next version of Q&A, there will be filter option that you can modify this.

    But you can apply this at the moment. Replace the attached files in qa/core/ and add the following code inside functions.php of your theme:

    function add_qa_to_search( $args ) {
    	$args["exclude_from_search"] = false;
    	return $args;
    }
    add_filter( 'qa_answer_register_post_type_args', 'add_qa_to_search');
    // To do the same for questions add this too:
    add_filter( 'qa_register_post_type_args', 'add_qa_to_search');

    Cheers,
    Hakan

    Edit: I have just noticed that there is a bug or documentation mistake in Wordpress files. It says exclude_from_search defaults to false, but in the codes it defaults to "null", which is neither false, nor true. Anyway, the above code will fix your issue.

  • thisisafakename
    • Site Builder, Child of Zeus

    Hi Hakan,

    thanks a lot for the answer and the code but I think you are talking about the site search and I was referring to the QA internal search box which does right now only search in the Topic header/body but not the answer text and this feel more like a bug then a feature. What is you take on that?

    EDIT: Your solution works on the site search! I have checked and can confirm, great work. But does not work with the QA build in search field.

    I am still trying to get an opinion on plugin specific searches. Is the user experience better with one search or is there an added value for when searching in a specific part of the site? Because not all users have access to all parts of the site a global search may list a lot of content which is not actually accessible for the user.

    Cheers, Alex

  • Hakan
    • The Incredible Smush

    Hi Alex,

    Yes, the search field on the questions menu is for only question search, not for answers search. The idea of that is to look if a question has been asked before and do not ask an already asked question.

    I cannot imagine a case answers should be searched there. Something like, an answer already submitted? User can use website search then.

    Because not all users have access to all parts of the site

    Why is it so? A global search should give only the results that user can access. If this is not the case, then you should fix that at first place.

    In any case, the intention of question search is just search for questions, not answers.

    Cheers,
    Hakan

  • thisisafakename
    • Site Builder, Child of Zeus

    Ok, understood. Then I will add a note to the search field, so its clear that it is for questions only.

    I do resprict acces via the membership plugin using e.g. URL groups with regex expressions. That is the only way I found to allow the user to see e.g. the list of questions but not the answers.

    Thanks again, great support.

    Maybe you can help me out with this one, too?
    https://premium.wpmudev.org/forums/topic/page-title-on-archive-missing-eg-category-test#post-253562
    Its is related to this one
    https://premium.wpmudev.org/forums/topic/custom-template-for-wiki-page#post-253367
    as I can not influence the template used for cat/tag archive.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.