We're merging with GenerateBlocks! Learn more here.

[Support request] wp_show_posts Shortcode with dynamic parameter

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support wp_show_posts Shortcode with dynamic parameter

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26452
    Vijay
    Participant

    Hi Tom,
    Lovin WP Show Posts Pro.
    I am applying the same hook (see code below) to all sub-pages of this page.

    The wp posts list is applied for post_tags (tags have been set up with Tag base suburbs).

    I am also using a shortcode [page_title] to dynamically display the page title at several place in the hook.

    https://marellagm.com.au/staging/local-areas/toorak/
    https://marellagm.com.au/staging/local-areas/balwyn/

    How can I use this shortcode within the [wp_show_posts] shortcode as illustrated below (or use php to get page title)?

    
    
    
    <!-- wp:paragraph -->
    <p>Some recent projects that we completed in [page_title]</p>
    <!-- /wp:paragraph -->
    
    <!-- wp:paragraph -->
    <p>Using the shortcode <code>{{wp_show_posts id="5181" settings="tax_term=Balwyn"}}</code></p>
    <!-- /wp:paragraph -->
    
    <!-- wp:shortcode -->
    [wp_show_posts id="5181" settings="tax_term=Balwyn"]
    <!-- /wp:shortcode -->
    
    <!-- wp:paragraph -->
    <p>Using the shortcode <code>{{wp_show_posts id="5181" settings="tax_term={{page_title}}"}}</code></p>
    <!-- /wp:paragraph -->
    
    #26479
    elvin
    Moderator

    Hi there,

    You can try Tom’s snippet here:
    https://wpshowposts.com/support/topic/shortcode-for-pods-taxonomies/#post-15797

    Example:

    <?php
    $object = get_queried_object();
    
    if ( isset( $object->term_id ) ) {
        $settings = array(
            'tax_term' => $object->term_id,
        );
    
        wpsp_display( 5181, $settings );
    }
    ?>

    What this does is, it gets the page’s term_id and assigns it as a tax_term for the WPSP list indicated within wpsp_display()

    Having term_id instead of title shouldn’t be an issue as tax_term‘s value can be either ID, slug or name.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.