Events Made Easy Forums How do I … WordPress search for events

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #64096
    blanch80
    Participant

    Hi Franky,

    I’m following the FAQ but am struggling to implement the search facility as detailed in the FAQ.

    I’m on a test site so am editing the main theme search.php – I’ve added the lines as shown in the FAQ but it’s not bringing any event detail back.

    URL: https://test.learning.necsu.nhs.uk/
    Event URL: https://test.learning.necsu.nhs.uk/events/traditional-music-session/

    I’m searching for ‘traditional’ but it’s finding no results. Search is working as expected for posts and pages.

    search.php looks like:

    $events = eme_wordpress_search_events();
    <?php
    /**
    * The template for displaying search results pages
    *
    * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
    *
    * @package WordPress
    * @subpackage Twenty_Twenty_One
    * @since Twenty Twenty-One 1.0
    */

    get_header();

    if ( have_posts() || !empty($events) ) {
    ?>
    <header class=”page-header alignwide”>
    <h1 class=”page-title”>
    <?php
    printf(
    /* translators: %s: Search term. */
    esc_html__( ‘Results for “%s”‘, ‘twentytwentyone’ ),
    ‘<span class=”page-description search-term”>’ . esc_html( get_search_query() ) . ‘</span>’
    );
    ?>
    </h1>
    </header><!– .page-header –>

    <div class=”search-result-count default-max-width”>
    <?php
    printf(
    esc_html(
    /* translators: %d: The number of search results. */
    _n(
    ‘We found %d result for your search.’,
    ‘We found %d results for your search.’,
    (int) $wp_query->found_posts,
    ‘twentytwentyone’
    )
    ),
    (int) $wp_query->found_posts
    );
    ?>

    <?php foreach ($events as $event) {
    print “<h2>“.$event[‘event_name’].” “.eme_localized_date($event[‘event_start’]).”</h2>”;
    print substr($event[‘event_notes’],0,250).”[…]”;
    print “<div style=’clear:both;’></div>”;
    } ?>

    </div><!– .search-result-count –>
    <?php
    // Start the Loop.
    while ( have_posts() ) {
    the_post();

    /*
    * Include the Post-Format-specific template for the content.
    * If you want to override this in a child theme, then include a file
    * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    */
    get_template_part( ‘template-parts/content/content-excerpt’, get_post_format() );
    } // End the loop.

    // Previous/next page navigation.
    twenty_twenty_one_the_posts_navigation();

    // If no content, include the “No posts found” template.
    } else {
    get_template_part( ‘template-parts/content/content-none’ );
    }

    get_footer();

    Hope you can help.

    #64109
    Franky
    Keymaster

    You have set your first line outside your php-tag, that will of course not work …

    #64111
    blanch80
    Participant

    Thanks Franky.

    I had it inside the php-tag and that didn’t work either, now looks like this and still doesn’t work – can’t see what I’m missing/done wrong.

    <?php
    /**
    * The template for displaying search results pages
    *
    * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
    *
    * @package WordPress
    * @subpackage Twenty_Twenty_One
    * @since Twenty Twenty-One 1.0
    */

    $events = eme_wordpress_search_events();
    get_header();

    if ( have_posts() || !empty($events) ) {
    ?>
    <header class=”page-header alignwide”>
    <h1 class=”page-title”>
    <?php
    printf(
    /* translators: %s: Search term. */
    esc_html__( ‘Results for “%s”‘, ‘twentytwentyone’ ),
    ‘<span class=”page-description search-term”>’ . esc_html( get_search_query() ) . ‘</span>’
    );
    ?>
    </h1>
    </header><!– .page-header –>

    <div class=”search-result-count default-max-width”>
    <?php
    printf(
    esc_html(
    /* translators: %d: The number of search results. */
    _n(
    ‘We found %d result for your search.’,
    ‘We found %d results for your search.’,
    (int) $wp_query->found_posts,
    ‘twentytwentyone’
    )
    ),
    (int) $wp_query->found_posts
    );
    ?>

    <?php foreach ($events as $event) {
    print “<h2>“.$event[‘event_name’].” “.eme_localized_date($event[‘event_start’]).”</h2>”;
    print substr($event[‘event_notes’],0,250).”[…]”;
    print “<div style=’clear:both;’></div>”;
    } ?>

    </div><!– .search-result-count –>
    <?php
    // Start the Loop.
    while ( have_posts() ) {
    the_post();

    /*
    * Include the Post-Format-specific template for the content.
    * If you want to override this in a child theme, then include a file
    * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    */
    get_template_part( ‘template-parts/content/content-excerpt’, get_post_format() );
    } // End the loop.

    // Previous/next page navigation.
    twenty_twenty_one_the_posts_navigation();

    // If no content, include the “No posts found” template.
    } else {
    get_template_part( ‘template-parts/content/content-none’ );
    }

    get_footer();

    #64112
    Franky
    Keymaster

    That should work just fine … I tried it here on my theme and got the expected results. Can you demo this on a site for me? Could I have some admin to test?

    #64113
    blanch80
    Participant

    Hi Franky,

    Just checked again and it turns out it’s a plugin conflict with the BuddyBoss platform which we use – thought I’d best let you know in case it comes up again. The search code you supplied works fine when that plugin isn’t activated.

    I’ve logged a support call with BuddyBoss to investigate.

    Thanks,
    David.

    #64114
    Franky
    Keymaster

    I don’t know that plugin, but if anything can be implemented on my end to resolve this conflict I’m willing to take a look at it (BuddyBoss will need to give feedback though).

    #64118
    blanch80
    Participant

    Cheers Franky – just waiting to hear back from them. I’ll let you know.

    #64152
    blanch80
    Participant

    Hi Franky,

    Just heard back from BuddyBoss, their reply is:

    This is to inform you that, when the BuddyBoss Platform is active, it actually replaces WordPress’s default searching with the BuddyBoss network search functionality and the custom code (which you provide in the FAQs) is not compatible with the BuddyBoss Network search.

    I don’t know if this is something you’d look at? I could provide you access to a staging site if required.

    Thanks,
    David

    #64153
    Franky
    Keymaster

    Sorry, but no. EME doesn’t use custom post types, so the only solution is for buddyboss to allow to hook into their system then. But it seems buddyboss also interferes with your theme then, which is very weird.

    #64154
    blanch80
    Participant

    Thanks Franky, BuddyBoss is a theme and platform plugin all in one. It’s an extension of BuddyPress.

    Is there a way to tag events in EME and for the tags to be searchable without the custom code you have shared in the FAQ?

    #64157
    Franky
    Keymaster

    If budyboss uses only custom post types that won’t help you. EME events have categories (managed all in EME), but not wordpress tags (switching EME to custom post types would lead to about a year of work …).

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.