Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #23968

    I want to remove the “Posted On: Date” text above the text of the Blog.

    How can that be done?

    #23970
    BoldGrid Support
    Keymaster

    Hey Markpr,
    Thanks for your question about removing the “Posted On Date” from your posts.

    With the amount of customization you’re doing, it’s recommended that you create a child theme so any modifications you make to the theme’s structure don’t get lost when doing updates.

    Solution #1: Removing the content from being generated.

    The correct way to do this is to override the method that is creating the links to suit your needs.  This is better for Search Engine Optimization since you’re not loading information that isn’t needed for your users.  While it’s a very small amount of code being removed, there’s less overhead, which in turn can increase your site’s speed.  Search engines don’t see with eyes, so when scraping your site, they will also see things that you hide, which may or may not be good for your site’s ranking in search engines.

    The method that creates this link is boldgrid_posted_on().  This is what is called a pluggable function, which means your child theme can override it to produce whatever custom markup you want to use for the post there.  The page you links for our-blog is an archive page.  Inside of your child theme’s method for boldgrid_posted_on(), you could conditionally check that by using the WordPress conditional is_archive().  There’s a lot of conditionals you can use within your template files to make the display of the content look and fit your exact need.  This gist is what you would add to your child theme’s functions.php file.

    You can see there at the top of the method, we check if we are on the archive page using the is_archive() method, and then return or abort running the rest of the code in that block.  This removes those sections from appear in your archive pages, but allows the other areas of your site to still have the markup when it’s needed.

    Solution #2: Using CSS to visibly hide the content.

    This solution would provide a way to hide the content visibly, but it’s still loaded on the page – just hidden to the naked eye.  People who use things like screen readers to visit your site or blog would also still “see” this content because they are reading the content of the page with their screen reader, and not visibly looking at it.

    The theme is designed in a way that allows everything to be contextually styled as you see fit.  You can see these classes on the body element.  Each page and post has a bunch of different things, so you can literally provide unique styles for just one post.

    We know that you want to hide this on the blog page, so we will start by looking at the body element.  There’s a blog class added to there as the top level we use.  If we right click on the “Posted On Date” and inspect the element, we will see that this is wrapped inside of a div with the entry-meta class.  This means we can target the element, and set it’s display property to “none” with the following CSS:

    .blog .entry-meta {
    display: none;
    }

    #23969
    mark_pr
    Member

    I went ahead and used solution #1. Although I needed to leave this code still in the function.php file:

    locate_template( ‘/inc/boldgrid-theme-framework-config/config.php’, true, true );
    require_once get_template_directory() . ‘/inc/boldgrid-theme-framework/boldgrid-theme-framework.php’;

    That worked for the blog page, but it didn’t remove the date on the individual post page (when you click the blog title on the blog page). On the individual post page, the date still shows.

    Here is what my current functions.php file has:

    <?php
    /**
    * Prints HTML with meta information for the current post-date/time and author.
    *
    * @see: https://www.boldgrid.com/support/question/in-the-blog-how-can-i-remove-the-posted-on-date-text/
    */
    locate_template( ‘/inc/boldgrid-theme-framework-config/config.php’, true, true );
    require_once get_template_directory() . ‘/inc/boldgrid-theme-framework/boldgrid-theme-framework.php’;
    function boldgrid_posted_on() {
    if ( is_archive() ) {
    return;
    }
    $time_string = ‘<time class=”entry-date published updated” datetime=”%1$s”>%2$s</time>’;
    if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) ) {
    $time_string = ‘<time class=”entry-date published” datetime=”%1$s”>%2$s</time><time class=”updated” datetime=”%3$s”>%4$s</time>’;
    }
    $time_string = sprintf( $time_string,
    esc_attr( get_the_date( ‘c’ ) ),
    esc_html( get_the_date() ),
    esc_attr( get_the_modified_date( ‘c’ ) ),
    esc_html( get_the_modified_date() )
    );
    $posted_on = sprintf(
    _x( ‘Posted on %s’, ‘post date’, ‘bgtfw’ ),
    ‘<a href=”‘ . esc_url( get_permalink() ) . ‘” rel=”bookmark”>’ . $time_string . ‘</a>’
    );
    $byline = sprintf(
    _x( ‘by %s’, ‘post author’, ‘bgtfw’ ),
    ‘<span class=”author vcard”><a class=”url fn n” href=”‘ . esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ) . ‘”>’ . esc_html( get_the_author() ) . ‘</a></span>’
    );
    echo ‘<span class=”posted-on”>’ . $posted_on . ‘</span><span class=”byline”> ‘ . $byline . ‘</span>’;
    }

     

    What change to the functions.php file could I make to remove the post date from the individual post pages?

    If you want to see what I mean:

    http://advantageaccountingsolutions.com/our-blog/

     

    Thanks again.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How can I remove the “Posted On: Date” text?’ is closed to new replies.