[Resolved] Category and Tags moved to the top and no longer working

Home Forums Support Category and Tags moved to the top and no longer working

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1119561
    Michael

    Hi,

    I previously used this code to move my category and tags to the top:

    add_action( 'generate_after_entry_title', 'tu_add_meta_below_title' );
    function tu_add_meta_below_title() {
        $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
        $categories_list = sprintf( '<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>',
    		esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
    			$tags_list
    	);
    
    	?>
    	<div class="entry-meta">
    		<?php echo $categories_list; ?>
    		<?php echo $tags_list; ?>
    	</div>			
    	<?php
    }		
    

    After the last Generate Press update, ONE of TWO sites that are set up almost the same way, lost the icons associated with the categories and tags and now they are on the same line at the top. The other site was unaffected. I deactivated all plugins except GP Premium and Code Snippets. Cleared Caches, Browers, etc. And it still is messed up. I can’t figure out why one site was affected and not the other.

    The site with the problem is in the ULR section. The site that is working correctly is linked in the left side of the footer on that site.

    #1120121
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    To bring the icons back and put them on their own lines, try this:

    .entry-header .cat-links,
    .entry-header .tags-links {
        display: block;
    }
    
    .entry-header .cat-links:before,
    .entry-header .tags-links:before {
        display: inline-block;
    }

    It’s also much easier to move those items to the top now. So instead of your code, try this:

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'categories',
            'tags',
            'date',
            'author',
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array_diff( $items, [ 'categories', 'tags' ] );
    } );
    #1153865
    Michael

    Hi Tom, thanks for the reply. I’m just now implementing this.

    The top code (putting them on their own lines) isn’t working. I’m getting this error from Code Snippets:

    Don’t Panic
    The code snippet you are trying to save produced a fatal error on line 1:

    syntax error, unexpected ‘.’, expecting end of file
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

    #1153936
    David
    Staff
    Customer Support
    #1154762
    Michael

    Lol, I’m stupid. That worked. πŸ˜€

    #1155108
    David
    Staff
    Customer Support

    Been there πŸ™‚
    Happy to be of help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.