Turning Function into a shortcode - Wordpress
<p>So I'm using this function below that works perfectly, however I want to convert it into a wordpress shortcode. </p>

<pre><code>&lt;?php
if( have_rows('pdf_download') ):
    while ( have_rows('pdf_download') ) : the_row(); ?&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href="&lt;?php the_sub_field('pdf_download'); ?&gt;"&gt;File Download&lt;/a&gt;&lt;/li&gt; 
        &lt;/ul&gt;
        &lt;?php

    endwhile;

else :

endif;

?&gt;
</code></pre>

<p>With the shortcode I'm creating I have different cases this is gonna be used for my custom taxonomy. All of the pages where I would use this function have a body class with single-prod and a postid-## . I was thinking about writing cases that target the specific post Id numbers that I want. I have something similar to this if anyone can help me </p>

<pre><code>function data_prod($atts) {

    global $post;

    switch($post-&gt;ID) {
        // Xbox One
        case 29:
            $query = new WP_Query(array(Do Something HERE));
            break;
        // Iphone 6s
        case 25:
            $query = new WP_Query(array(Do Something HERE));
            break;
        // iWatch
        case 17:
            $query = new WP_Query(array(Do Something HERE));
            break;
    }

    $content = '';
    $content .= '&lt;ul&gt;';
        while($query-&gt;have_rows('pdf_download')) : $query-&gt;the_row();
            $content .= '&lt;li&gt;&lt;a href="&lt;?php the_sub_field('pdf_download'); ?&gt;"&gt;File Download&lt;/a&gt;&lt;/li&gt; ';
        endwhile;
    $content .= '&lt;/ul&gt;';

    return $content;
}
add_shortcode('data_prod', 'data_prod');
</code></pre>