• Resolved c.thomas

    (@cthomas-1)


    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)
  • I am not a coder, but I do know your { at the end of function sc_profile_shortcode(){ is not being properly paired with the } at the end of your file. So, I am guessing there is a <?php -to- ?> somewhere that is not nested properly.

    Thread Starter c.thomas

    (@cthomas-1)

    Yes, you are right!

    ***tired eyes need help ??

    Have a good night (or day)

    Carla

    ***tired eyes need help ??

    I have only one eye that can read, so I cheated by using NotePad++ to just look at colors! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Creating a Shortcode Plugin’ is closed to new replies.