• Resolved etruchan

    (@etruchan)


    I am need help with a page template code I created. I want the “featured image to automatically to pop up at the top of the page. Currently everything else works the way I want it to but I am not certain my code is as clean as it should be. Any help appreciated. Here is the code:

    <?php
    /*
    Template Name: Promotion Page
    */
    ?>
    
    <?php get_header(); ?>
    <div class="art-sheet clearfix">
                <div class="art-layout-wrapper">
                    <div class="art-content-layout">
                        <div class="art-content-layout-row">
                            <div class="art-layout-cell art-content"><article class="art-post art-article">
    
                    <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 100%" >
            <p style="text-align: center;">
    			the_post_thumbnail()</p>
        </div>
        </div>
    </div>
    <div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 55%" >
            <p><?php get_sidebar('top'); ?>
    			<?php
    
    			if (have_posts()) {
    				/* Start the Loop */
    				while (have_posts()) {
    					the_post();
    					get_template_part('content', 'page');
    				}
    			} else {
    				theme_404_content();
    			}
    			?>
    			<?php get_sidebar('bottom'); ?></p>
        </div><div class="art-layout-cell layout-item-0" style="width: 45%" >
            <p style="text-align: center;"><iframe width="400" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=CornerStone+Sports+Pub+%26+Eatery,+South+Main+Street,+Oconomowoc,+WI&aq=0&oq=cornerstone+sports&sll=44.900771,-89.56949&sspn=13.335608,28.54248&ie=UTF8&hq=&hnear=&t=m&ll=43.111436,-88.49976&spn=0.001371,0.002146&z=18&iwloc=lyrftr:m,3262774016263517484,43.110896,-88.499792&output=embed&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent"></iframe></p><p style="text-align: center;"><?php echo do_shortcode('[widget id="ermm_widget-2"]'); ?></p>
        </div>
        </div>
    </div>
    <div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 100%" >
            <h3>Questions or COncerns</h3><p>If you need any further clarification about this event, please <a href="http://www.cornerstonesportspub.com/cornerstone/contact-us/">contact us</a>. stop in at 24 S Main St, Oconomowoc, WI 53066, or call 262.560.1368</p><p>We will see you soon.</p>
        </div>
        </div>
    </div>
    </div>
    
    </article></div>
                        </div>
                    </div>
                </div>
        </div>
    <?php get_footer(); ?>


    [Please be sure to use the code buttons when posting code – as is, your code may have been damaged]

Viewing 7 replies - 1 through 7 (of 7 total)
  • This is probably what you want:

    <?php
    /*
    Template Name: Promotion Page
    */
    ?>
    
    <?php get_header(); ?>
    <div class="art-sheet clearfix">
                <div class="art-layout-wrapper">
                    <div class="art-content-layout">
                        <div class="art-content-layout-row">
                            <div class="art-layout-cell art-content"><article class="art-post art-article">
    
                    <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 100%; text-align: center; " >
    
    			<?php
    				if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    				echo '<img src="'. the_post_thumbnail() .'" />';
    				}
    			?>
        </div>
        </div>
    </div>
    <div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 55%" >
            <p><?php get_sidebar('top'); ?>
    			<?php
    
    			if (have_posts()) {
    				/* Start the Loop */
    				while (have_posts()) {
    					the_post();
    					get_template_part('content', 'page');
    				}
    			} else {
    				theme_404_content();
    			}
    			?>
    			<?php get_sidebar('bottom'); ?></p>
        </div><div class="art-layout-cell layout-item-0" style="width: 45%" >
            <p style="text-align: center;"><iframe width="400" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=CornerStone+Sports+Pub+%26+Eatery,+South+Main+Street,+Oconomowoc,+WI&aq=0&oq=cornerstone+sports&sll=44.900771,-89.56949&sspn=13.335608,28.54248&ie=UTF8&hq=&hnear=&t=m&ll=43.111436,-88.49976&spn=0.001371,0.002146&z=18&iwloc=lyrftr:m,3262774016263517484,43.110896,-88.499792&output=embed&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent&wmode=transparent"></iframe></p><p style="text-align: center;"><?php echo do_shortcode('[widget id="ermm_widget-2"]'); ?></p>
        </div>
        </div>
    </div>
    <div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 100%" >
            <h3>Questions or COncerns</h3><p>If you need any further clarification about this event, please <a href="http://www.cornerstonesportspub.com/cornerstone/contact-us/">contact us</a>. stop in at 24 S Main St, Oconomowoc, WI 53066, or call 262.560.1368</p><p>We will see you soon.</p>
        </div>
        </div>
    </div>
    </div>
    
    </article></div>
                        </div>
                    </div>
                </div>
        </div>
    <?php get_footer(); ?>

    The functional portion being

    <?php
    				if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    				echo '<img src="'. the_post_thumbnail() .'" />';
    				}
    			?>

    which is necessary to echo out the thumbnail in an image tag if the thumbnail exists.

    Thread Starter etruchan

    (@etruchan)

    Dynomite!!! That did it thank you.

    Here is one more question I have. I am trying to use this code in conjunction with the promotional slider plugin.

    I am trying to figure out where to put this code so that the template pops up as an option for the actual page template for the promotional slider. The problem I have is that it is technically a custom post type and I can’t figure out where to put the file for functionality or if I need to add some functionality elsewhere.

    If you you have any insight I would appreciate it.

    Big picture, what are you trying to do with this? You want to attach featured images to the slider posts?

    Thread Starter etruchan

    (@etruchan)

    I figured out the solution. To my previous dilemma. I got rid of promo slider and went with smooth slider. Solved all the problems.

    Thread Starter etruchan

    (@etruchan)

    Green,

    You were super helpful on the last code. Maybe you can help this time. I created a Post Page Template php to utilize the featured image on the left side of a post and on the right series of custom fields created by the custom field template plugin. I m utilizing the shortcodes generated by the plugin.

    Here is my code:

    <?php
    /*
    Template Name Posts: New Works
    */
    ?>
    <?php get_header(); ?>
    <div class="art-sheet clearfix">
                <div class="art-layout-wrapper">
                    <div class="art-content-layout">
                        <div class="art-content-layout-row">
                            <div class="art-layout-cell art-content">
                    <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 100%; text-align: center; " >
    			<?php
    				if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    				echo '<img src="'. the_post_thumbnail() .'" />';
    				}
    			?>
        </div>
        </div>
    </div>
    <div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 55%" >
    			<?php
    				if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    				echo '<img src="'. the_post_thumbnail() .'" />';
    				}
    			?>
        </div>
        <div class="art-layout-cell" style="width: 45%" >
           <p> Job Name <?php echo do_shortcode("[cf-shortcode plugin="acf" field="job_name"]"); ?></p> <p> Job Location <?php echo do_shortcode("[cf-shortcode plugin="acf" field="job_location"]"); ?><p> Job Type <?php echo do_shortcode("[cf-shortcode plugin="acf" field="job_type"]"); ?> </p>
        </div>
        </div>
    </div>
    </div>
    </div>
                        </div>
                    </div>
                </div>
        </div>
    <?php get_footer(); ?>

    Thread Starter etruchan

    (@etruchan)

    WordPress keeps kicking back: php-syntax-error-unexpected-t-string

    The code identified is as follows:
    <p> Job Name <?php echo do_shortcode("[cf-shortcode plugin="acf" field="job_name"]"); ?></p> <p> Job Location <?php echo do_shortcode("[cf-shortcode plugin="acf" field="job_location"]"); ?><p> Job Type <?php echo do_shortcode("[cf-shortcode plugin="acf" field="job_type"]"); ?> </p>

    I also eliminated the duplicate code:

    <div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout">
        <div class="art-content-layout-row">
        <div class="art-layout-cell" style="width: 100%; text-align: center; " >
    			<?php
    				if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    				echo '<img src="'. the_post_thumbnail() .'" />';
    				}
    			?>
        </div>
        </div>
    </div>

    Thread Starter etruchan

    (@etruchan)

    I figured it out.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Page Template Code assistance’ is closed to new replies.