Forums Forums Search & Filter Pro How to modify or style the search results when using shortcode method

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #144318

    I am using the shortcode method to display my results. How do I modify the results styling or even add custom fields to the results? For example, in your demo, you are showing reviews. How do I add that? How do I style my results? I can’t find any template file that allows me to move or add the search results content around?

    I’m testing but the results page will be on one of these two URL’s.

    https://www.vrfitnessinsider.com/game-reviews-results/results/

    https://www.vrfitnessinsider.com/reviews/

    Please help!

    Trevor
    #144334

    The style of the results depends on the Display method you use (as you say, you are using the Shortcode one right now). You would need to cutomise the results.php file, using php snippets from the WordPress Codex and other resources. Start here though:

    https://www.designsandcode.com/documentation/search-filter-pro/search-results/using-a-shortcode/#Customising_the_Results

    There is, for example, a free addon for Search & Filter pro for Visual Composer/Page Builder, which means you can use their Post grid element and then use their tools to style it. See this post:

    https://support.searchandfilter.com/forums/topic/can-we-change-template-desing/#post-136727

    Anonymous
    #144383

    Thank you for your support! I have followed the directions and have created a new directory and am modifying the new results.php. Is there a way to find all of the php snippets that are available on a page? Example: I created a custom field called “Developer” and want to display that on the search results. How do I find the php snippet for that or anything else that is exposed on the post type?

    Trevor
    #144408

    It depends whether you used the free ACF plugin to make the custom fields, another plugin, or simply wordpress. For WordPress default stuff, I find stackexchange a great place for snippets.

    So, this phrase:

    stackexchange php echo wordpress custom field

    is what I would search for in Google. That reveals that the PHP function is get_post_meta, so I look that up in the codex and get this:

    <?php echo get_post_meta( get_the_ID(), ‘developer’, true );?>

    Anonymous
    #144448

    Thanks for this! So I’m using the new results.php under search-filter directory that I created. There are php snippets already in there.

    <?php the_category(); ?>
    <?php the_date(); ?>
    <?php the_permalink(); ?>”>
    <?php the_excerpt(); ?>
    <?php the_permalink(); ?>”>
    <?php the_title(); ?>

    Where are these defined? How do I see all of them associated with my custom post type?

    I was trying to move <?php the_category(); ?> to my custom HTML but the snippet is bringing back HTML.

      and

    • tags. All I want is the name of the category (text only). How can I change that?

      How do I get the category permalink? I tried <?php the_category_permalink(); ?> <?php the_categorypermalink(); ?> these don’t work. There has to be a snippet for it?

      As I was testing I thought about how I can bring back the author name. So I tried <?php the_author(); ?> . It worked! Is there a way to see ALL snippets associated with my custom post type Game Review?

      https://www.vrfitnessinsider.com/reviews/
      Here is a post
      https://www.vrfitnessinsider.com/review/game-review-testing-4/

      Thank you for any help you can give!

    Anonymous
    #144450

    Also, the date on my search results is skipping some of the results. I am using <?php the_date(); ?>

    https://www.vrfitnessinsider.com/reviews/

    There are 4 search results on this page. The 2nd and 3rd don’t have dates. But they do have dates. When you filter and get one of them in a new search they show the dates.

    Do you know why this is happening?

    Thanks!

    Trevor
    #144579

    Two posts, and quite a few questions. I will try to answer them n turn:

    Q1. There are php snippets already in there …
    Q1a. Where are these defined?
    Q1b. How do I see all of them associated with my custom post type?

    A1a. These are WordPress functions, so you can look them up and code examples/snippets in the WordPress Codex (programming guide) – just Google it.
    A1b. I am not sure I understand this question. However, when you define a CPT, you have the option to decide what meta data is stored for each CPT. Does it have tags, does it have categories, does it have comments, etc.

    Q2. All I want is the name of the category (text only). How can I change that?
    A2. When you ask for Categories or Taxonomies (or other fields), the response might be a single value OR an array. WordPress has no way of knowing, so, int the main, it replies with an array. You need to get code snippets from StackExchange, for example, ask Google How to output WordPress categories attached to a post as a list stackexchange. There are a lot of posts showing how, depending on your needs.

    Note, it may be necessary to employ a third party coder to help you with this. Everybody’s needs are different, so there is not a simple, generic solution.

    Q3. The date thing.
    A3. Read this:

    https://codex.wordpress.org/Function_Reference/get_the_date

    The note at the top explains what you are seeing. You might need to use:

    <?php echo get_the_date();?>

    Sometimes you have to echo the reply, sometimes the function outputs directly without the need for echo.

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