• Resolved amnaachohan

    (@amnaachohan)


    Hey

    Thanks a lot firstly for making such a wonderful plugin ..

    I have a question , see i have 6 custom type posts , and each custom type post have different custom fields and taxonomies ..

    i want to show the custom fields in the search results that can possible but overwriting the loop, but my question is my each custom type post have different custom fields which i want to show in search result.

    Let’s say i have one custom type post events and other is classified.

    in the event search result i want to show custom fields from event and like wise for classified the custom fields from classified.

    so basically i need different loops for each custom type post.. so can i have different search page for each custom type post.

    Hope my question is clear ??

    Thanks a lot in advance ??

    https://www.ads-software.com/plugins/advanced-custom-post-search/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Creare

    (@shane-welland)

    If its only the few custom fields that are different I’d be tempted to say put them in a conditional statement…

    <?php
    $post_type = get_post_type( get_the_ID() );

    switch( $post_type)
    {
    case ‘<post_type_name_here>’:
    CUSTOM FIELDS GO HERE
    break;
    case ‘<other_post_type_name_here>’:
    OTHER CUSTOM FIELDS GO HERE
    break;
    }
    ?>

    You don’t need to use a switch if there are only two post types with different custom fields though. Let me know if this helps.

    Thread Starter amnaachohan

    (@amnaachohan)

    Hey

    Yeah , this is great idea , i don’t know why it didn’t come in my mind(stupid me) .. well Thank you genius ^_^ .. i will try this today .. i have 6 custom type posts so switch would be needed .. Thanks a lot .. ??

    Plugin Author Creare

    (@shane-welland)

    No worries =D, it’s probably not the cleanest way if you wanted to refine it more I’m sure you could but it’ll do the trick! Hope its helped anyway

    Thread Starter amnaachohan

    (@amnaachohan)

    And your suggestion work like a cheese cake ?? ,Thanks a lot ..

    I will post my code here soon so if anyone else need similar thing it can help them ..

    Thanks again ..

    Hello and thank you for a great plugin!

    I am a newbie to php and wondering where to paste the above code? My situation: I have two custom post types and have no idea how to get both to appear in the search results, only one at a time as is available in the admin panel. I understand the purpose of the above code, but not sure where to place it, nor if it is appropriate for me?

    Thank you in advance for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Different search pages for each custom type post’ is closed to new replies.