[Resolved] Category list at top of post

Home Forums Support [Resolved] Category list at top of post

Home Forums Support Category list at top of post

Viewing 15 posts - 31 through 45 (of 46 total)
  • Author
    Posts
  • #936450
    Randy

    Sorry for the delay: I took a dinner break.

    We’re further along, but not quite there yet. We have:

    Posted June 17, 2019 Categories Kids/Teens, Military, Podcasts, Space, Work Leave a comment

    when it used to be:

    Posted June 17, 2019 in Categories Kids/Teens, Military, Podcasts, Space, Work
    Leave a comment

    (adding “in” and the Comments link on a new line)

    #936460
    Leo
    Staff
    Customer Support
    #936480
    Randy

    Yes, that fixed the Comments part. How can we get “in” in there?

    (Almost there! Thanks.)

    #936492
    Leo
    Staff
    Customer Support

    Sorry final update.

    Update the snippet to this:

    //Change the GeneratePress post meta function
    add_filter( 'generate_post_date_output', 'tu_categories_to_date' );
    add_filter( 'generate_category_list_output', '__return_false' );
    add_filter( 'generate_tag_list_output', '__return_false' );
    add_filter( 'generate_show_comments', '__return_false' );
    function tu_categories_to_date() {
    	$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
    	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    		$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>' . $time_string;
    	}
    	
    	$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() )
    	);
    	
    	// If our date is enabled, show it.
    	$time_string = sprintf( 'Posted <span class="posted-on">%s </span>', // WPCS: XSS ok, sanitization ok.
    		$time_string
    	);
    		
        $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
        $categories_list = sprintf( 'in <span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
            _x( 'Categories', 'Used before category names.', 'generatepress' ),
            $categories_list
        );
    	
    	$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
    	$tags_list = sprintf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    		_x( 'Tags', 'Used before tag names.', 'generatepress' ),
    		$tags_list
    	);
    
    	echo $time_string . $categories_list;
      
    	if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
    		echo '<span class="comments-link">';
    			comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
    		echo '</span>';
    	}
    }

    And the CSS to this:

    .entry-header .comments-link {
        display: block;
    }

    I tested the code so it should all work πŸ™‚

    #936505
    Randy

    “Should” being the operative word. πŸ™‚

    The posted line looks perfect. But no Comments count/link.

    #936510
    Leo
    Staff
    Customer Support
    #936514
    Randy

    I feel your pain (getting late here too).

    Just noticed the word “Posted” is not on the front of the date line.

    No worries if you need to sleep on it first.

    #936515
    Leo
    Staff
    Customer Support
    #936516
    Randy

    Woo hoo! Looks like everything is set.

    Tell Tom not to break it again. πŸ˜‰

    Thanks, and have a good night.

    #937168
    Leo
    Staff
    Customer Support
    #939051
    Randy

    Me again.

    See https://randysrandom.com/independence-day/

    …another of my sites. This one uses Facebook comments, rather than WP’s, so I don’t need a Comments link. I’ve tried a few iterations of the ideas here to get:

    Posted on 4 July 2017 in Holidays, Thinking, Wow

    …but I haven’t cracked it yet. (It currently shows “Categories” but I don’t actually need that word.) This is in Posts, not Pages. TIA

    #939066
    Leo
    Staff
    Customer Support

    Don’t actually see the word Category:
    https://www.screencast.com/t/knZyvBrjvDj3

    Have you figured this out?

    #939069
    Randy

    All but the “in” part.

    I’m using this code:

    //Change the GeneratePress post meta function
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'date',
            'categories',
        );
    } );
    #939071
    Leo
    Staff
    Customer Support

    Try this CSS:

    span.posted-on:after {
        content: " in";
    }
    #939755
    Randy

    Thanks, Leo, that fixed it.

Viewing 15 posts - 31 through 45 (of 46 total)
  • You must be logged in to reply to this topic.