Creating a Shortcode Plugin
-
I am having problems with creating a shortcode for a plugin that I have created.
GOAL: to use a shortcode to display custom fields that are within a custom post type (created using a custom plugin).
As of now, I am receiving the following parse error — UNEXPECTED END OF FILE — for the following code:
<?php function sc_profile_shortcode(){ wp_reset_postdata(); $args = array ( 'post_type' => 'profile', ); $the_query = new WP_Query( $args ); ?> <!--Custom WP_Query loop--> <?php if( $the_query->have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php // Retrieves the stored value from the database $meta_value = get_post_meta( get_the_ID(), 'meta-text', true ); // Checks and displays the retrieved value if( !empty( $meta_value ) ) { ?> <div class="text-center fullname"> <h1><?php echo $meta_value; ?></h1> </div> <div class="text-center"> <h1>Cosmetology Student</h1> </div> <?php } endwhile; endif; // end of the loop. ?> }
Thanks in advance for your help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Creating a Shortcode Plugin’ is closed to new replies.