I am working on a static website, www.example.com

and have installed wordpress in a subdirectory: www.example.com/blog.

I have created a custom elemnt on the home page which pulls in the latest blog. To do this I have included the following code:


The problem I am having is that this is pulling in the meta description as well as some other meta tags which are not needed, what is the best way to fix this?

FYI, this is the custom code which pulls in the latest blog:

<section class="homeBlog">
                <h2>Read Our Latest Blog</h2>
                <div class="homeBlogContainer">

                    <?php if (has_post_thumbnail()) : ?>
                        $image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

                        <div class="tm-featured-image" style="background: url('<?php echo $image; ?>') #FFF no-repeat; background-size: cover;">
                            <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
                            <img class="uk-invisible" src="<?php echo $image; ?>" alt="<?php echo $image_alt; ?>">

                    <?php endif; ?>

                    <div class="home-blog-text">
                            <?php $the_query = new WP_Query( 'posts_per_page=1' ); ?>                   
                            <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> 
                            <div class="articleMeta">
                                <div class="profileImage">
                                    <?php echo get_avatar( get_the_author_meta( 'ID' ), 100 ); ?>

                                <div class="profileAuthor"> 
                                    <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
                                    <p class="profileMeta">
                                            $date = '<time datetime="'.get_the_date('Y-m-d').'">'.get_the_date().'</time>';
                                            printf(__('%s <br> %s', 'warp'), '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'" title="'.get_the_author().'">'.get_the_author().'</a>', $date);
                                        <?php edit_post_link(__('Edit', 'warp'), ' / <i class="uk-icon-pencil"></i> ',''); ?>

                            <?php the_excerpt(__('(more…)')); ?>    

                            <p class="btn">
                                <strong><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">read more</a></strong>


This is because you call get_header() which already require your theme header.php, in which the meta tags are defined.

You should learn how to use get_header() in the Wordpress Codex

To summarize:

  • You must rename your wp-blog-header.php file to header-blog.php and place it in your wordpress theme directory.

  • Then you can require it using this function : get_header('blog').

If your header is the same on everypage, you can just replace the header.php and call it with get_header().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.