• Resolved Anonymous User

    (@anonymized-15688342)


    I’m inserting a custom post type in to a “normal” post and I can’t get the both to show up in the search result when searching for a word only present in the custom post. If I insert a custom post in to another custom post of the same type it works just fine. I’m not sure if it’s a problem with Relevansi or the insert page plugin.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Paul Ryan

    (@figureone)

    In Relevanssi settings, do you have:
    * the custom post type checked in the list of post types to index
    * “Expand shortcodes in post content” checked
    * “Custom fields to index” set to “visible”
    After doing that, make sure to rebuild the index before checking again.

    As far as I can tell, nothing in Insert Pages should be causing this behavior. It’s merely a shortcode in the post content, so we just want to configure Relevanssi to expand that shortcode when it builds its index. Also note this comment in Relevanssi settings: “If you use shortcodes to include dynamic content, Relevanssi will not keep the index updated, the index will reflect the status of the shortcode content at the moment of indexing.”

    Thread Starter Anonymous User

    (@anonymized-15688342)

    Thanks for the tips, I hadn’t tried to set custom fields to index to ‘visible’ but it didn’t help. I’m not getting this problem with other shortcodes which expands and is found by the relevanssi search, and I have no problems getting the result of the original custom post. It’s only the combination of inserting one post type in to another post type that fails me.

    Plugin Author Paul Ryan

    (@figureone)

    Strange. If I were you, I’d hook into the relevanssi_content_to_index filter and inspect the content for the specific post IDs you’re having trouble with.
    https://www.relevanssi.com/user-manual/filter-hooks/

    Example:

    function your_relevanssi_indexing_data( $data, $post ) {
      // Show indexing data for post ID 123.
      if ( $post->ID == 123 ) {
        error_log( print_r( $data, true ) );
      }
    }
    add_filter( 'relevanssi_indexing_data', 'your_relevanssi_indexing_data', 10, 2 );

    That way you might be able to see what is going wrong with the indexing.

    Thread Starter Anonymous User

    (@anonymized-15688342)

    I think I found the problem. I’m using these lines in function.php to force a template for all inserted pages:

    // Override all inserted pages with a custom display.
    function my_override_display( $display ) {
    return ‘insertPage.php’;
    }

    add_filter( ‘insert_pages_override_display’, ‘my_override_display’ );

    This works just fine for that purpose but it does something to mess up the searching. Removing this from function.php and the search results works as expected.

    • This reply was modified 8 years, 6 months ago by Anonymous User.
    Plugin Author Paul Ryan

    (@figureone)

    Interesting. It’s possible that relevanssi indexing happens without fully bootstrapping the theme, making the custom theme template not load. You may be able to customize that display override filter to do something different if it detects the relevanssi indexing context (and do ‘insertPage.php’ otherwise).

    Thread Starter Anonymous User

    (@anonymized-15688342)

    My wp-skills are waaay to crummy for that 🙂 I do have an alternative solution (if possible).

    The only reason why I’m force loading a custom template for my inserted pages is that I want to include the content of the post + the meta edit link for the inserted post (that I renamed “edit inserted post” in the template). I think this enhances the insert page plugin a lot since it allows me or editors to look at a page from the front end, identify that there’s an inserted post and just click on the “edit inserted post” link to edit the inserted post. Instead of having to first go edit -> find the short code for the inserted post -> go to the inserted post -> edit inserted post.

    Is this making any sense?

    • This reply was modified 8 years, 6 months ago by Anonymous User.
    Thread Starter Anonymous User

    (@anonymized-15688342)

    I got this reply from Relevanssi support:

    ”Indeed, Relevanssi indexing works in a different context than the front end users.

    Try disabling that filter in relevanssi_pre_indexing_query action hook: that’s run before Relevanssi index-building.”

    I’ll try to try this out!

    Thread Starter Anonymous User

    (@anonymized-15688342)

    Ok, I don’t know if this makes any difference but I was removing the insert_pages_override_display filter doesn’t help. Removing it and setting the display to “use a custom template” breaks the search as well.

    Thread Starter Anonymous User

    (@anonymized-15688342)

    This is what I got from the relevanssi devs:

    add_action(‘relevanssi_pre_indexing_query’, ‘remove_my_filter’);
    function remove_my_filter() {
    remove_filter(‘insert_pages_override_display’, ‘my_override_display’);
    }

    Perhaps this can be tweaked to remove some other function used when setting a custom template?

    Plugin Author Paul Ryan

    (@figureone)

    If I were you I would step back and inspect what Relevanssi is actually indexing for the page in question. Is it just the shortcode? Or maybe something in your custom template is causing problems in the relevanssi context?

    You can use the code sample I provided above to print out the output to the web server error log so you can look at what Relevanssi is indexing for the page in question. You can do that for both the inserted page, and the page that it’s inserted into.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘custom post type within post not shown’ is closed to new replies.