Search content of child posts

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search content of child posts

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 5 years, 7 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10753
    Ana Vuksanovic
    Ana Vuksanovic
    Participant

    Hi,

    first of all Thank you for this wonderful search plugin. We have set up it in no time and plugin works great.

    I have question two question about advance use of this plugin:

    1. Search content and child posts
    We have structured posts where mother post in content has only shorcode how is rendered from child posts.
    The real content is saved in child posts (with special post type and status depending on what is the content: text, img, video, gallery…) that are linked to the mother post.

    My question is: we would like to setup search to search content of child posts and as a result return linked mother post.

    The way we were thinking to do that is to include into search all post types and post statuses (from mother and a child) and then filter and replace the serch result before showing (replace child post with mother post ) .
    Is this possible or there is another way and what hook or filter you suggest we should use to achive that?

    2. Filtering by formula
    On advance search we would like to offer our users to search by e.g. distance radius of geo location -> to achive that – is it possible to use regular search that will be additionaly filtered by our formula before showing the results?

    Thank you in advance.

    Br,
    Ana

    #10766
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Ana,

    Thank you for the details, I will try to answer everything the best way I can.

    1. Search content and child posts
    If I understand correctly, the parent posts only contain a shortcode, which displays the actual content, which is gathered from various child elements. I believe the Index Table engine feature might be able to do the trick for you. It is a secondary engine, which requires building an index, but it’s capable of reading most executed shortcode contents.
    Please read the following chapters in the documentation carefully, on how to generate and use it:
    What is the index table?
    Generating the index table
    Enabling the index table

    2. Filtering by formula
    This is a much more complicated issue, I recall someone already asked something similar, and the conclusion was that it’s not possible, without extensive modifications to the code.

    The built in filters interact with the database directly, for the maximum performance. This works well with any statical value, where you can apply an equasion, bigger or smaller or a between operator. Calculacting distance however is much more complicated, and the fundamental problem is that it is always relative to something – and it’s usually given by two coordinates.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #10767
    Ana Vuksanovic
    Ana Vuksanovic
    Participant

    Thank you for your reply and advices.

    Rearding child posts, we are already using asp index data engine.
    I have turned on the option ‘Execute shortcodes ‘ -> but this unfortunately didn’t do the trick. Content from child posts by executing shortcode in mother content didn’t parse child content into asp_index table as content terms of mother post.

    They are parsed only if I include child post type into index -> but then they are parsed under post_id (doc) of child post and not the mother post.
    Is there another way to do this?

    Rearding formula, is it maybe posible by
    ‘asp results’ – to hide results that don’t qualify by this additional formula or by additional condition
    or by ‘asp_query_args’ -> to exclude list of post_ids calculated by formula / condition – before ajax search main query?

    Thanks again.

    Br,
    Ana

    #10773
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Ana,

    1. Search content and child posts

    I’ve looked up the code to maybe somehow append the content of child posts to the parent before the indexing method is invoked. Unfortunately I haven’t put any filters there, but we can solve that by making minor modifications:

    I.) Make sure to have a back-up of everything on your server in case something goes wrong.
    II.) Open up the wp-content\plugins\ajax-search-pro\includes\classes\etc\indextable.class.php file and scroll to line 412 where you should see this:

    $content = $the_post->post_content;

    and change that to:

    $content = apply_filters( 'asp_post_content_before_tokenize_clear', $the_post->post_content, $the_post );

    III.) Now that we have a filter to use, put this into the functions.php file in your active theme directory:

    This code will get the child posts and append their content to the parent element content before indexing.

    IV.) Re-create the index table, and let’s hope it works.

    2. Filtering by formula

    I would recommend using the ‘asp_query_args’ filter if you can get the post IDs to exclude at that stage – because it’s not a post process, and therefore the post count will be more accurate.

    Something like this:

    Change the line:

    $ids = your_formula_to_get_ids_array( $phrase );

    to your solution. The $ids variable must be an array of the post IDs you want to exclude, or an empty array().

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #10779
    Ana Vuksanovic
    Ana Vuksanovic
    Participant

    Thank you so much – you deserve 10-star rating.

    Upgrade for indexing content of child posts worked like a charm.

    Just a question about plugin upgrade – will I have to take care about this change inside indextable.class.php or will it become a part of next version?

    For Filtering by formula – I’ll try this later today and let you know about outcome.

    This plugin is realy great, flexible and has fabulous support.

    Br,
    Ana

    #10792
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    ..will I have to take care about this change inside indextable.class.php or will it become a part of next version?
    It will be a part of the upcoming version of course, so you don’t have to worry about it in the future πŸ™‚

    Thank you very much for your kind words!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.