• Resolved DillonKavanagh

    (@dillonkavanagh)


    Hi,

    On single pages and all standard implementation pages such as save posts, it works great. The issue I have is in any custom loops It appears the post data is not passing to the shortcode.

    I appreciate this is not the standard set-up but is there any way I can pass the post id to the shortcode. Or get [simplicity-save-for-later] working in a custom loop outside the single page?.

    Thanks in advance. Examples below.

            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
              <?php echo do_shortcode('[simplicity-save-for-later]'); ?>
              <?php echo the_title(); ?>
              <?php endwhile; endif; ?>
    
              <?php
              $my_query = new WP_Query( "p=$id" );
              if ( $my_query->have_posts() ) {
              	while ( $my_query->have_posts() ) {
              		$my_query->the_post();
                  echo do_shortcode('[simplicity-save-for-later]');
                  echo the_title();
              		// the_content();
              	}
              }
              wp_reset_postdata();
              ?>
    
              <?php
              query_posts( "p=$id" );
              while ( have_posts() ) : the_post();
              echo do_shortcode('[simplicity-save-for-later]');
              echo the_title();
              endwhile;
              // Reset Query
              wp_reset_query();
              ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Not working in custom loops’ is closed to new replies.