• Hello,

    I have been trying to convert this working php code into a WordPress Shortcode. Could someone help me out?

    <form action=”#” method=”get”>
    <select name=”page_id” id=”page_id” onchange=”document.location = this.value”>
    <option value=”test”>Select Document</option>
    <?php

    $q1_args = array(
    ‘tag’ => ‘hoki-3’
    );
    $q1_posts = get_posts( $q1_args );

    $q2_args = array(
    ‘media-tags’ => ‘hoki-4’
    );
    $q2_posts= get_posts( $q2_args );

    $final_posts = array_merge( $q1_posts, $q2_posts );

    foreach ( $final_posts as $key => $post ) {

    setup_postdata( $post );

    echo ‘<option value=”‘. get_the_permalink() . ‘”>’. get_the_title() .'</option>’;

    }
    ?>
    </select>
    <noscript>
    <input type=”submit” value=”View” />
    </noscript>
    </form>

    Thanks,

    Tim

  • The topic ‘Turn working code into a Shortcode’ is closed to new replies.