Creating shortcode
-
I have made a custom post type called ‘modules’. Now I want to make a shortcode containing this modules output, but for some reason this is not working.
I know I have to return something, so what’s wrong with my code? When I enter it like this, the page get’s stuck loading (https://prnt.sc/s5q4xq).
/** * Module slider */ add_shortcode('module_slider', 'wbgoe_module_slider'); function wbgoe_module_slider() { $output = function() { $args = array( 'post_type' => 'modules', 'posts_per_page' => 7, 'orderby' => 'date', 'order' => 'ASC' ); $query = new WP_Query($args); while($query->have_posts()): $query->the_post(); ?> <embed src="<?php the_field('url'); ?>" width="100%" height="600px"></embed> <?php endwhile; }; return $output; }
- This topic was modified 3 years, 11 months ago by .
- This topic was modified 3 years, 11 months ago by .
- This topic was modified 3 years, 11 months ago by .
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Creating shortcode’ is closed to new replies.