• Resolved sandranql

    (@sandranql)


    Hi Pod plugin author,

    Background
    I am trying to create a dropdown menu for the items in the a CPT pod named course.

    I have put in the following php code in the function.php file and POD template as the screenshots.

    In the Function.php File:

    `function wpse34320_type_dropdown( $post_type )
    {
    $posts = get_posts(
    array(
    ‘post_type’ => $post_type,
    ‘numberposts’ => -1
    )
    );
    if( ! $posts ) return;

    $out = ‘<select id=”wpse34320_select”><option>Select a Course</option>’;
    foreach( $posts as $p )
    {
    $out .= ‘<option value=”‘ . get_permalink( $p ) . ‘”>’ . esc_html( $p->post_title ) . ‘</option>’;
    }
    $out .= ‘</select>’;
    return $out;
    }

    In the POD Template

    ?<?php echo wpse34320_type_dropdown( ‘course’ ,1); ?>
    Class Size: {@min_class_size} to {@max_class_size}

    Problem
    However, the dropdown menu is duplicated according to the number of pod items there are. (E.g. 3 courses => 3 dropdown menus).
    ?
    Please see here: https://one-eduworld.com/listings/yamaha-music-school/

    Advice/ The way forward
    I can’t figure out what is the problem despite reading up most of the documentation on the pod website. I will greatly appreciate if you could point me in the right direction to figure things out. Thank you very much!

    Many thanks,
    Sandra

    • This topic was modified 3 years, 6 months ago by sandranql.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @sandranql

    You are using PHP within a Pod template, this is deprecated and shouldn’t be done!

    Also, since Pod templates are meant for post loops and post detail page they shouldn’t be used for single usages like this.
    It’s better to make sure this function is only called on the location you need it. For this reason I’d add is in your theme templates instead of Pod templates.

    Cheers, Jory

    Thread Starter sandranql

    (@sandranql)

    Hi Jory,

    Thank you very much for your advice! I will try them out. I really appreciate your help.

    Cheers,
    Sandra

    • This reply was modified 3 years, 6 months ago by sandranql.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Remove Duplicate Dropdown menus for CPT Pod?’ is closed to new replies.