[Resolved] Search Page Customisations

Home Forums Support [Resolved] Search Page Customisations

Home Forums Support Search Page Customisations

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2043770
    Matt

    Hi Guys,

    I just have a couple of questions around search results page.

    1. Header Element. I have a block element with dynamic Header Block. Rather than showing the search result page title ie. ‘Search result: example’, the dynamic header is populated with the title of the first returned post. Am i doing something wrong here?

    2. Content Template for search result item. I have several post types (custom) and also regular posts and pages being returned in the search results. Can the dynamic text options be configured to populate the type of result? ie. ‘Page’, “post”, ‘custom post type 1’… So for each search result the user can see if it is a page, a post, a custom post type etc?

    Thanks

    #2043930
    Ying
    Staff
    Customer Support

    Hi Matt,

    1. You are not doing something wrong, it’s the normal behavior as search result page doesn’t really have a title. So the dynamic block can’t pull the title, instead it pulls the title of the first search result.

    2. I don’t think so Unfortuanly.

    #2044126
    Matt

    Would it be possible to use a shortcode or something to place the post type name in a content template?

    #2044157
    Ying
    Staff
    Customer Support

    You can give this PHP snippet a try:

    add_shortcode( 'show_post_type', 'custom_show_post_type' );
    function custom_show_post_type() {
        $postType = get_post_type_object(get_post_type());
            if ($postType) {
            return esc_html($postType->labels->singular_name);
        }
    }

    Then use [show_post_type] as the shortcode.

    #2044197
    Matt

    That’s perfect.. Thankyou!

    #2044247
    Ying
    Staff
    Customer Support

    You are welcome 🙂

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