• philippenantes

    (@philippenantes)


    Does what is says.

    Would be great if shortcode could accept en ID as a parameter.
    Would be great if description would show the slug of the cpt, which is ‘code-snippets’
    Would be great also to have a straight forward example of a query to dispplay all snippets on a page.

    For those who would like to see an example, this is what i did in a template page :

    // WP_Query arguments
    $args = array (
    ‘post_type’ => ‘code-snippets’,
    ‘posts_per_page’ => ‘-1’,
    ‘order’ => ‘ASC’,
    );

    // The Query
    $myquery = new WP_Query( $args );

    while ($myquery->have_posts()) {
    $myquery->the_post();
    ?>
    <article id=”page-<?php the_ID(); ?>” class=”page” role=”article”>
    <header class=”page-header”>
    <h1 class=”page-title”><?php the_title(); ?></h1>
    </header>
    <?php echo do_shortcode(‘[snippet slug=’.$post->post_name.’ lang=php]’); ?>
    </article>
    <?php }
    wp_reset_postdata();

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Justin Sternberg

    (@jtsternberg)

    Would be great if shortcode could accept en ID as a parameter.

    Good news, that’s possible using the id parameter in the shortcode.

    Would be great if description would show the slug of the cpt, which is ‘code-snippets’

    Not sure I follow there.

    Would be great also to have a straight forward example of a query to dispplay all snippets on a page.

    Sounds like you got it sorted?

    Thread Starter philippenantes

    (@philippenantes)

    >Would be great if shortcode could accept en ID as a parameter.

    Good news, that’s possible using the id parameter in the shortcode.

    \o/
    Tried to with no luck. I have to admit, I didn’t dig very deep. Surely an issue on my side.

    Would be great if description would show the slug of the cpt, which is ‘code-snippets’

    I mean, namely mention the CPT slug on the description tab of the plugin.

    Sounds like you got it sorted?

    Yes sure ! nothing difficult here. Only intended to help future ppl.

    Anyway, thank you so much, great plugin, convenient, and as mentionned in another comment, the use of a CPT makes it extremely flexible and re-usable.

    Awasome !
    Cheers ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Excellent’ is closed to new replies.