Support Forum » User Profile

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • sunil@sunil.co.nz[email protected]
    Participant

    Update:

    While I've been researching this issue I've found an issue with the terminology I'm using:

    I don't just want search results to encompass custom meta, I also need them to encompass custom taxonomies (I've just learnt that these things are not the same).

    So for a cpt of type 'book' with a custom taxonomy of type 'genre', I'd like a search that is limited to the cpt and that has the search string 'horror' return all results that have 'horror' attached as a value to the custom taxonomy 'genre'.

    in reply to: How can I enable a search form to search in custom meta? #38557
    sunil@sunil.co.nz[email protected]
    Participant

    Thank you Long.

    I was able to adapt the answers in that WPE thread to create a search that only returns results from a custom post type. Basically I created a custom search form and then I use pre_get_posts to alter the query.

    This leaves me with the other half of my challenge: allowing the search function to encompass data within custom fields. The article you've pointed to is good, but ultimately simply says to hand off that task to a third-party plugin. This isn't an option for me.

    Can you point to how people are doing this without plugins?

    From what I gather, I think I need to alter the search query further, also using pre_get_posts. But I haven't been able to find any documentation or articles on exactly how to do it.

    in reply to: Unable to display related posts: Fatal error #17041
    sunil@sunil.co.nz[email protected]
    Participant

    I figured it out.

    In the function to display fields from the related CPT's, I should have used the correct id: the id of the relationship that I initially created.

    So the corrected function reads like this:

    $connected = new WP_Query( array(
    ‘relationship’ => array(
    ‘id’ => ‘connect_conversations_to_people’,
    ‘from’ => get_the_ID(), // You can pass object ID or full object
    ),
    ‘nopaging’ => true,
    ) );
    while ( $connected->have_posts() ) : $connected->the_post();
    ?>
    “><?php the_title(); ?>
    <?php
    endwhile;
    wp_reset_postdata();
Viewing 3 posts - 1 through 3 (of 3 total)