• <?php get_header(); ?>
    
    		<div id="container" class="row-inner">
    			<?php if( ot_get_option('blog_layout') == 'full-width' ) : ?>
    
    				<div id="content">
    
    					<?php
    
    					if ( have_posts() ) :
    						while ( have_posts() ) : the_post();
    
    the_post_thumbnail('small-thumbnail'); 
    
    							get_template_part( 'content', get_post_format() );
    
    						endwhile;
    					else :
    						get_template_part( 'content', 'none' );
    
    					endif;
    
    					?>
    
    					<nav class="post-navigation" role="navigation">
    						<?php posts_nav_link(' ', __('Newer posts', 'care'), __('Older posts', 'care'));?>
    					</nav>
    
    				</div><!-- #content -->
    
    			<?php else : ?>
    
    			<div id="content" class="<?php if( ot_get_option('blog_layout', 'right-sidebar') == 'right-sidebar' ) { echo 'float-left'; } else { echo 'float-right'; } ?>">
    
    					<?php
    					if ( have_posts() ) :
    						while ( have_posts() ) : the_post();
    							get_template_part( 'content', get_post_format() );
    						endwhile;
    					else :
    						get_template_part( 'content', 'none' );
    					endif;
    					?>
    
    					<nav class="post-navigation" role="navigation">
    						<?php posts_nav_link(' ', __('Newer posts', 'care'), __('Older posts', 'care'));?>
    					</nav>
    
    				</div><!-- #content -->
    
    				<div id="sidebar" class="<?php if( ot_get_option('blog_layout', 'right-sidebar') == 'right-sidebar' ) { echo 'float-right'; } else { echo 'float-left'; } ?>">
    					<?php get_sidebar('blog'); ?>
    				</div>
    			<?php endif; ?>
    		</div><!-- #container -->
    
    <?php get_footer(); ?>

    I’ve been watching videos of how to insert certain elements in between the code above but everyone’s code in their index.php file looks nothing like my php code above. Any help is appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • get_template_part( 'content', get_post_format() );

    and

    get_template_part( 'content', 'none' );
    Thread Starter holubp

    (@holubp)

    Thanks Rajesh!

    any idea how to permalink the thumbnail i have in there? I tried

    <a href="<?php the_permalink(); ?>">the_post_thumbnail('small-thumbnail');</a>

    but it basically crashed my site so I removed it.

    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('small-thumbnail'); ?></a>
    Thread Starter holubp

    (@holubp)

    thanks alchymyth but when I add that in, it only links the first blog post and all of my other images in the post excerpts below disappear.

    Here is what my index.php looks like

    <?php get_header(); ?>
    
    		<div id="container" class="row-inner">
    			<?php if( ot_get_option('blog_layout') == 'full-width' ) : ?>
    
    				<div id="content">
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('small-thumbnail'); ?></a>
    
    <?php
    
    					if ( have_posts() ) :
    						while ( have_posts() ) : the_post();
    
    							get_template_part( 'content', get_post_format() );
    
    						endwhile;
    					else :
    						get_template_part( 'content', 'none' );
    
    					endif;
    
    					?>
    
    					<nav class="post-navigation" role="navigation">
    						<?php posts_nav_link(' ', __('Newer posts', 'care'), __('Older posts', 'care'));?>
    					</nav>
    
    				</div><!-- #content -->
    
    			<?php else : ?>
    
    			<div id="content" class="<?php if( ot_get_option('blog_layout', 'right-sidebar') == 'right-sidebar' ) { echo 'float-left'; } else { echo 'float-right'; } ?>">
    
    					<?php
    					if ( have_posts() ) :
    						while ( have_posts() ) : the_post();
    the_post_thumbnail('small-thumbnail');
    							get_template_part( 'content', get_post_format() );
    						endwhile;
    					else :
    						get_template_part( 'content', 'none' );
    					endif;
    					?>
    
    					<nav class="post-navigation" role="navigation">
    						<?php posts_nav_link(' ', __('Newer posts', 'care'), __('Older posts', 'care'));?>
    					</nav>
    
    				</div><!-- #content -->
    
    				<div id="sidebar" class="<?php if( ot_get_option('blog_layout', 'right-sidebar') == 'right-sidebar' ) { echo 'float-right'; } else { echo 'float-left'; } ?>">
    					<?php get_sidebar('blog'); ?>
    				</div>
    			<?php endif; ?>
    		</div><!-- #container -->
    
    <?php get_footer(); ?>

    Any ideas?

    Blog is here

    https://www.homeopathicpluscentre.com/wordpressnew/?page_id=2946

    If you want to add something into the actual content, you’ll need to look for the files that get_template_part() anre including. As an example, when you have this:

    get_template_part( 'content', get_post_format() );

    And the post has a format of ‘page’, it will look for these files (in this order) and use the first one that it finds.

    content-page.php
    content.php

    That’s where you’ll find the actual output for the content.

    To find out more, look at the WordPress Template Hierarchy. That will show you where the requests go and what template files can be used.

    but when I add that in, it only links the first blog post and all of my other images in the post excerpts below disappear

    in your first posted code, you had the featured image code in the right place (within the loop, somewhere after the while() code); replace it with the suggested code for linking the image to the post.

    Thread Starter holubp

    (@holubp)

    alchymyth I took your advice and replaced

    the_post_thumbnail('small-thumbnail');

    in the original code i posted in my first post, with

    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('small-thumbnail'); ?></a>

    and my blog page goes white and inaccessible…

    my mistake – I assumed that inserting html sections into php code would be a known procedure for anybody customizing WordPress themes.

    you would need to close the php tag before the hhmtl section, and then open it again to continue with php …
    please learn the basics of html and php so that you can at least edit php files safely.

    in detail, replace this section:

    while ( have_posts() ) : the_post();
    
    the_post_thumbnail('small-thumbnail'); 
    
    							get_template_part( 'content', get_post_format() );
    
    						endwhile;

    with:

    while ( have_posts() ) : the_post(); ?>
    
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('small-thumbnail'); ?></a>
    
    <?php get_template_part( 'content', get_post_format() );
    
    						endwhile;
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Where exactly in this code does the content actually come in?’ is closed to new replies.