Home › Forums › Back End › My First WordPress Theme – PHP and function output problems › Reply To: My First WordPress Theme – PHP and function output problems
February 22, 2015 at 1:18 pm
#196548
Historical Forums User
Participant
Sorry, I thought that codenvy link would show the source code for you (you have to double click on the project name for it to open), Here is the source code that is outputting the blog posts in the right hand column of the main content area (the middle column if you count the sidebar). The live site is at http://akilahtzuberi.com/blog.
<?php
//OUTPUT SECTION 1 POSTS
$args = array( 'post_type' => 'section-1', 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="post_introbox">';
echo '<div class="post_titlebox">';
echo '<h3 id="post-<?php the_ID(); ?>"><a href="';
echo the_permalink();
echo '">';
echo the_title();
echo '</a></h3>';
echo '<p><span><a href="author/"';
echo get_the_author_link();
echo '</span></a>';
//echo the_author(); </span></a>;
echo ' • ';
echo the_date('m.d.Y'); '</p>';
echo '</div>'; //close titlebox
echo '<div class="containerz">';
echo '<a href="';
echo the_permalink();
echo '">';
echo add_image_size( 'front-featured', 374, 250, array( 'center', 'center' ) ); // Hard crop left top
if ( has_post_thumbnail() ) {; // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( 'front-featured' );
}
echo '</a></div>';
echo '<div class="section_link_box"> ';
echo '<span class="section1">';
echo '<a href="/blog/';
echo get_post_type( $post );
echo '">';
$category = get_the_category( $custompost );
echo $category[0]->cat_name;
echo '</a></span></div>';//CLOSE SECTION_LINK_BOX
echo '<div class="spacer_one"></div>';
echo '<div class="introtext section1">';
echo the_excerpt();
echo '<p class="more">';
echo '<a href="';
echo the_permalink();
echo '">';
echo 'Continue Reading</a></p>';
echo '<div class="clearfloat"></div>';
echo '</div></div>'; //close introtext
endwhile;
?>
<?php
//OUTPUT SECTION 2 POSTS
$args = array( 'post_type' => 'section-2', 'posts_per_page' => 2 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="post_introbox">';
echo '<div class="post_titlebox">';
echo '<h3 id="post-<?php the_ID(); ?>"><a href="';
echo the_permalink();
echo '">';
echo the_title();
echo '</a></h3>';
echo '<p><a href="author/';
echo get_the_author();
echo '"><span>';
echo the_author(); '</span></a>';
echo ' • ';
echo the_date('m.d.Y'); '</p>';
echo '</div>'; //close titlebox
echo '<div class="containerz">';
echo '<a href="';
echo the_permalink();
echo '">';
echo add_image_size( 'front-featured', 374, 250, array( 'center', 'center' ) ); // Hard crop left top
if ( has_post_thumbnail() ) {; // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( 'front-featured' );
}
echo '</a></div>';
echo '<div class="section_link_box"> ';
echo '<span class="section2">';
echo '<a href="/blog/';
echo get_post_type( $post );
echo '">';
$category = get_the_category( $custompost );
echo $category[0]->cat_name;
echo '</a></span></div>';//CLOSE SECTION_LINK_BOX
echo '<div class="spacer"></div>';
echo '<div class="introtext section2">';
echo the_excerpt();
echo '<p class="more">';
echo '<a href="';
echo the_permalink();
echo '">';
echo 'Continue Reading</a></p>';
echo '<div class="clearfloat"></div>';
echo '</div></div>'; //close introtext
endwhile;
echo wp_reset_query();
?>
<?php
//OUTPUT SECTION 3 POSTS
$args = array( 'post_type' => 'section-3', 'posts_per_page' => 2 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="post_introbox">';
echo '<div class="post_titlebox">';
echo '<h3 id="post-<?php the_ID(); ?>"><a href="';
echo the_permalink();
echo '">';
echo the_title();
echo '</a></h3>';
echo '<p><a href="author/';
echo get_the_author();
echo '"><span>';
echo the_author(); '</span></a>';
echo ' • ';
echo the_date('m.d.Y'); '</p>';
echo '</div>'; //close titlebox
echo '<div class="containerz">';
echo '<a href="';
echo the_permalink();
echo '">';
echo add_image_size( 'front-featured', 374, 250, array( 'center', 'center' ) ); // Hard crop left top
if ( has_post_thumbnail() ) {; // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( 'front-featured' );
}
echo '</a></div>';
echo '<div class="section_link_box"> ';
echo '<span class="section3">';
echo '<a href="/blog/';
echo get_post_type( $post );
echo '">';
$category = get_the_category( $custompost );
echo $category[0]->cat_name;
echo '</a></span></div>';//CLOSE SECTION_LINK_BOX
echo '<div class="spacer"></div>';
echo '<div class="introtext section3">';
echo the_excerpt();
echo '<p class="more">';
echo '<a href="';
echo the_permalink();
echo '">';
echo 'Continue Reading</a></p>';
echo '<div class="clearfloat"></div>';
echo '</div></div>'; //close introtext
endwhile;
echo wp_reset_query();
?>
<?php
//OUTPUT SECTION 4 POSTS
$args = array( 'post_type' => 'section-4', 'posts_per_page' => 2 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="post_introbox">';
echo '<div class="post_titlebox">';
echo '<h3 id="post-<?php the_ID(); ?>"><a href="';
echo the_permalink();
echo '">';
echo the_title();
echo '</a></h3>';
echo '<p><a href="author/';
echo get_the_author();
echo '"><span>';
echo the_author(); '</span></a>';
echo ' • ';
echo the_date('m.d.Y'); '</p>';
echo '</div>'; //close titlebox
echo '<div class="containerz">';
echo '<a href="';
echo the_permalink();
echo '">';
echo add_image_size( 'front-new644-featured', 1000, 582, array( 'top', 'left' ) ); // Hard crop left top
if ( has_post_thumbnail() ) {; // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( 'front-featured' );
}
echo '</a></div>';
echo '<div class="section_link_box"> ';
echo '<span class="section4">';
echo '<a href="/blog/';
echo get_post_type( $post );
echo '">';
$category = get_the_category( $custompost );
echo $category[0]->cat_name;
echo '</a></span></div>';//CLOSE SECTION_LINK_BOX
echo '<div class="spacer"></div>';
echo '<div class="introtext section4">';
echo the_excerpt();
echo '<p class="more">';
echo '<a href="';
echo the_permalink();
echo '">';
echo 'Continue Reading</a></p>';
echo '<div class="clearfloat"></div>';
echo '</div></div>'; //close introtext
endwhile;
echo wp_reset_query();
?>