WordPress.org

Ready to get started?Download WordPress

Forums

Removal of blog post header - on per post basis? (9 posts)

  1. escmode
    Member
    Posted 5 years ago #

    Hello,

    Kind of a newbie to this and just setting up the site.....

    I'm looking for a plug-in that will allow me to remove the 'blog post header' on an individual post basis.

    Example: if you go to my site: http://www.escmodemusic.com/blog/ and look at the first post (Digidesign), I want to remove the header containing:
    'Category Top Stories : Edit : no comments » '.

    But I want to do this on a per post basis. Is there any plug-in to do this?

    I've looked and tried a few plug-ins but didn't get very far :(

    Thanks,
    Patrick

  2. jrawle
    Member
    Posted 5 years ago #

    Under what circumstances do you want to remove it? When comments are disabled? Or is it that some content would better be placed on a "Page", which won't have that line?

    If you want more precise control, you can use a custom field, and it'll require a small modification to your theme.

    Let us know what you are trying to do!

  3. escmode
    Member
    Posted 5 years ago #

    Thanks Jrawle.

    I'll try and explain.....

    Firstly, I want sections of this site to have more of a 'store' feel, so on certain posts I want to remove the blog header, so the post looks more like a product listing (I'll be adding my affiliate links).

    It's not that I want to remove the header only when comments are disabled... I want to be able to remove that header completely on certain posts ( to achieve the above).

    So, I guess as you say, I need more precise control, but not sure where to start with modifying my (fluidity) theme. I was kind of hoping there would be a plug-in to achieve this.

    Thanks again.

    Patrick

  4. jrawle
    Member
    Posted 5 years ago #

    Incidentally, this isn't really the "header", which in WordPress usually means everything that goes at the top of every page. But I'll stick with your terminology for this thread!

    You can use a custom field, for example, you can call it show_header. If you set the values of "show_header" to "no" for a post, you want it to miss off the header.

    You need to add the following to your theme, around the code that shows the header. This will probably be in index.php, single.php, and maybe other files, in your theme's directory.

    <?php $show_header=get_post_custom_values('show_header'); if(trim($show_header[0])!="no") { ?>
    
    ... code to display the "header" here ...
    
    <?php } ?>

    That should do it! Be sure to keep a backup copy of your theme in case you break it!

  5. escmode
    Member
    Posted 5 years ago #

    Hi Jrawle... in the index page of my theme ( fluidity) I've found the following code:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="post-header">
    <h3 class="timr">
    <?php the_time('F jS, Y') ?>

    I'm guessing ' <div class="post-header"> ' is where your code needs to be placed.... could you show me how insert it into the above?

    Cheers,
    Patrick

  6. escmode
    Member
    Posted 5 years ago #

    No joy so far... bit of a dumb-ass when it comes to programming. Here's how I've added your code:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <?php $show_header=get_post_custom_values('show_header'); if(trim($show_header[0])!="no") { ?>
    <div class="post-header">
    <?php } ?>
    <h3 class="timr">
    <?php the_time('F jS, Y') ?>

    I've made a test post creating a Custom Field with a Key of 'show_header' (no quotes) and a value of 'no' (again no quotes)..... and nothing is happening. I'm guessing I've placed the code wrong???

    grrr.... was hoping there would be a plug-in for this as I would have thought this would have been a popular feature request.

  7. escmode
    Member
    Posted 5 years ago #

    Hi all... I still haven't resolved this. Any more advice would be greatly appreciated. Below is the code of my theme index page:

    <?php get_header(); ?>

    <div id="left">
    <div id="content">

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="post-header">
    <h3 class="timr">
    <?php the_time('F jS, Y') ?>
    </h3>
    <h2><i>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?>
    </i></h2>
    <p class="postmetadata">
    <!-- from <?php the_author() ?> -->
    Category
    <span class="catr">
    <?php the_category(', ') ?>
    </span> :
    <?php edit_post_link('Edit', '<span class="editr">', ' : </span>'); ?>
    <span class="commr">
    <?php comments_popup_link('no comments »', '1 comment »', '% comments »'); ?>
    </span></p>
    </div>
    <div class="entry">
    <?php the_content('read the rest of this entry... »'); ?>
    </div>
    </div>
    <div style="clear: both; height: 15px;"></div>
    <?php endwhile; ?>
    <div class="navigation">
    <div class="alignleft">
    <?php next_posts_link('← next posts') ?>
    </div>
    <div class="alignright">
    <?php previous_posts_link('previous posts →') ?>
    </div>
    </div>
    <?php else : ?>
    <h2 class="center">Not found</h2>
    <p class="center">There is nothing.</p>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <?php endif; ?>

    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Can anyone show me exactly how and where to place the code as kindly suggested by 'jrawle'... or if there is an alternative?

    Thanks,
    Patrick

  8. jrawle
    Member
    Posted 5 years ago #

    Apologies for the absence, I haven't visited this site for a few days.

    You need to find the code that outputs the text you want to remove, i.e. the category, number of comments, etc. As I said, this isn't the header, it's usually called the postmetadata in WordPress parlance.

    You need to surround the entire section you want to remove with my code. I reckon this is a good place to start:

    <?php $show_meta=get_post_custom_values('show_meta');
    if(trim($show_meta[0])!="no") { ?>
    
    <p class="postmetadata">
    <!-- from <?php the_author() ?> -->
    Category
    <span class="catr">
    <?php the_category(', ') ?>
    </span> :
    <?php edit_post_link('Edit', '<span class="editr">', ' : </span>'); ?>
    <span class="commr">
    <?php comments_popup_link('no comments »', '1 comment »', '% comments »'); ?>
    </span></p>
    
    <?php } ?>

    Note that I've changed the name of the custom field to show_meta to better reflect what it does.

    Hope that helps!

  9. escmode
    Member
    Posted 5 years ago #

    Ok, some success. I've managed to update the 'single.php' file, so the single post shows without the post-meta-data (helps when you know the right terminology;-).

    Here's where I placed your code - after some trial and error I got the result I was looking for:

    <?php get_header(); ?>

    <div id="post">

    <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>

    <div class="post-meta" id="main-post">
    <h1 class="post-title">" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></h1>
    <?php $show_meta=get_post_custom_values('show_meta');
    if(trim($show_meta[0])!="no") { ?>

    <div class="postedby">
    <div class="post-status">
    <?php _e('Posted by'); ?> <?php the_author_posts_link(); ?> in <?php the_time('F jS, Y') ?>  <?php edit_post_link('Edit', '', ''); ?>
    </div>
    <div class="comment-stats"><?php comments_popup_link('No Comment Yet', '1 Comment', '% Comments'); ?></div>
    </div>
    <div class="fileunder">
    <div class="atgcat"><?php _e('Posted in'); ?>: <?php the_category(', ') ?>     <?php if(function_exists("UTW_ShowTagsForCurrentPost")) : ?><?php UTW_ShowTagsForCurrentPost("commalist", array('last'=>' and %taglink%', 'first'=>'Tags in: %taglink%',)) ?><?php else : ?><?php if(function_exists("the_tags")) : ?><?php the_tags() ?><?php endif; ?><?php endif; ?> </div>
    </div>

    <?php if(file_exists(TEMPLATEPATH . '/social.php')): ?>
    <?php include (TEMPLATEPATH . '/social.php'); ?>
    <?php else: ?>
    <?php endif; ?>
    <?php } ?>

    <div class="post-content">
    <?php the_content("Read more..."); ?>

    <h3>You Should Also Check Out This Post:</h3>

      <?php gte_random_posts(); ?>

    Note: I've since changed my theme since the original post

    Issue is now getting the same thing accomplished on the homepage. My index file looks fairly sparse, complete code is:

    <?php include (TEMPLATEPATH . '/options/options.php'); ?>
    <?php get_header(); ?>

    <!--[if !IE]>INTI GLOBAL POSTPAGE FUNCTIONS<![endif]-->

    <?php if(($tn_mz_blog_style == 'list') || ($tn_mz_blog_style == 'blog')){ ?>
    <div id="post-index">
    <?php } else { ?>
    <div id="post">
    <?php } ?>

    <?php if($tn_mz_blog_style == TRUE){ ?>
    <?php include (TEMPLATEPATH . '/layouts/' .$tn_mz_blog_style. '.php'); ?>
    <?php } else { ?>
    <?php include (TEMPLATEPATH . 'layouts/blog.php'); ?>
    <?php } ?>

    <div class="clear-fix"></div>

    </div>

    <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    I've also found the same block of code in 'page.php' & 'category.php' and updated the files with no effect on the homepage. Actually, I've been through all the php files and only found the 'post-meta' in the above mentioned files. So.... stuck on fixing the homepage.

    Anyhow... it's no biggie really, would be nice to have the same function on the homepage but if it can only be fixed on the 'single' post page, I'm ok with that.

    Thanks very much JRawle... I have another question coming shortly....haha

Topic Closed

This topic has been closed to new replies.

About this Topic