Home>Support>Display post date only on certain categories

Display post date only on certain categories

I am building a site, where the main menu contains links to different post categories.

If possible, I would like to be able to show post date with every article in one category, and no post date in posts in another category.

Both on the archive pages and on single post pages.

Is that possible?

Thanks in advance.

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 9 years, 1 month ago Andrew Misplon
    Hi, I Work Here

    Hi Hans

    With some Custom CSS it is possible. Can you send me links to each page with directions as to which must show the date and which must not.

    Thanks

  2. 9 years, 1 month ago zkagen

    Hi Andrew,
    Show: Posted on xxxx by xxxxx on this archive: http://wptest01.zkagen-marketing.dk/category/kategori1/
    Do NOT show on this archive: http://wptest01.zkagen-marketing.dk/category/kategori2/
    Thanks in advance.
    HC.

  3. 9 years, 1 month ago Andrew Misplon
    Hi, I Work Here

    Thanks, let’s try:

    .category-kategori2 .entry-meta {
    	display: none;
    }
    
  4. 9 years, 1 month ago zkagen

    Works beautifully!

    Is it possible to hide: Category Archives:
    – from both page headers?

  5. 9 years, 1 month ago Andrew Misplon
    Hi, I Work Here

    Super, glad to hear that helped.

    Try:

    .category-kategori1 .blue-header h1,
    .category-kategori2 .blue-header h1 { 
    	display: none;
    }
    
  6. 9 years, 1 month ago zkagen

    Hi Andrew,

    Thanks for the very fast feedback :-)

    That sort of works, but it hides the entire header. I only want to hide: “Category Archives:” not the category name.

    Can that be done?

  7. 9 years, 1 month ago Andrew Misplon
    Hi, I Work Here

    There isn’t any tag wrapping the “Category Archives” part of the string so you’d need to filter the function itself. To do that you’d need to insert the following into the functions.php file of your child theme:

    if( !function_exists( 'vantage_get_archive_title' ) ) :
    /**
     * Return the archive title depending on which page is being displayed.
     * 
     * @since vantage 1.0
     */
    function vantage_get_archive_title(){
    	$title = '';
    	global $wp_query;
    	if ( is_category() ) {
    		$title = sprintf( __( 'Category Archives: %s', 'vantage' ), '<span>' . single_cat_title( '', false ) . '</span>' );
    
    	}
    	elseif ( is_tag() ) {
    		$title = sprintf( __( 'Tag Archives: %s', 'vantage' ), '<span>' . single_tag_title( '', false ) . '</span>' );
    
    	}
    	elseif ( is_author() ) {
    		the_post();
    		$title = sprintf( __( 'Author Archives: %s', 'vantage' ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' );
    		rewind_posts();
    
    	}
    	elseif ( is_day() ) {
    		$title = sprintf( __( 'Daily Archives: %s', 'vantage' ), '<span>' . get_the_date() . '</span>' );
    
    	}
    	elseif ( is_month() ) {
    		$title = sprintf( __( 'Monthly Archives: %s', 'vantage' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );
    
    	}
    	elseif ( is_year() ) {
    		$title = sprintf( __( 'Yearly Archives: %s', 'vantage' ), '<span>' . get_the_date( 'Y' ) . '</span>' );
    
    	}
    	elseif ( !empty($wp_query->query_vars['taxonomy']) ) {
    		$value = get_query_var($wp_query->query_vars['taxonomy']);
    		$term = get_term_by('slug',$value,$wp_query->query_vars['taxonomy']);
    		$tax = get_taxonomy( $wp_query->query_vars['taxonomy'] );
    		$title = sprintf( __( '%s: %s', 'vantage' ), $tax->label, $term->name );
    	}
    	else {
    		$title = __( 'Archives', 'vantage' );
    	}
    	
    	return apply_filters('vantage_archive_title', $title);
    }
    endif;
    

    You can then edit the string from within that function.

  8. 9 years, 1 month ago zkagen

    Okay, I will try that.

    One final question.

    Is it possible to hide the featured image on both the single post page and the archive page, but only for a certain category?

    Show feature image on these pages:
    http://wptest01.zkagen-marketing.dk/category/kategori1/
    http://wptest01.zkagen-marketing.dk/nyhed-fire-er-super-fantastisk/

    Hide featured images on these pages:
    http://wptest01.zkagen-marketing.dk/category/kategori2/
    http://wptest01.zkagen-marketing.dk/med-nyhed-tre-bliver-det-rigtig-godt/

  9. 9 years, 1 month ago Andrew Misplon
    Hi, I Work Here

    This would hide the featured image for the given archive:

    .category-kategori2 .entry-thumbnail {
        display: none;
    }
    
    .category-kategori2 article.post.post-with-thumbnail-icon .entry-main, article.page.post-with-thumbnail-icon .entry-main {
        width: 100%;
    }
    

    As you’ve seen we’re using body classes to do all of this. This is what the body tag looks like on the single post you linked to:

    <body class="single single-post postid-35 single-format-standard siteorigin-panels responsive layout-full has-sidebar has-menu-search mobilenav">
    

    There is no identifier for the category it belongs to.

    If you set the post format to “Aside” then you could hide the featured image as follows:

    .single-format-aside .entry-thumbnail {
    	display: none;
    }
    
  10. 9 years, 1 month ago zkagen

    Hi Andrew,

    The code:

    .category-kategori2 .entry-thumbnail {
        display: none;
    }
    
    .category-kategori2 article.post.post-with-thumbnail-icon .entry-main, article.page.post-with-thumbnail-icon .entry-main {
        width: 100%;
    }
    

    Seems to do the job nicely.

    Thanks!

  11. 9 years, 1 month ago Andrew Misplon
    Hi, I Work Here

    Glad that helped :)

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More