Note: I have very little knowledge of PHP but by reading the code I do have an idea of what’s being used and where.
I don’t want to use categories on my blog, and have been using a single generic category name just so they don’t all say “Uncategorized.” I really like that clicking on the post format icons to the right of the post will load a page for all posts of the same type (e.g. all gallery posts, or all quote posts). Post types are really just another category, and if anything, I’d prefer to categorize my blog by type. I would love to display a text link of the post format above the post title, in place of the currently displayed categories-link.
Looking at the PHP for a post format, I found the following span that puts the category name above the post title (line 29 of content-image.php) –
<?php $categories_list = get_the_category_list( __( ', ', 'ryu' ) ); if ( $categories_list && ryu_categorized_blog() ) echo '<span class="categories-links">' . $categories_list . '</span>'; ?>
I want to grab just the post format URL (not the icon) and put it in the entry header somehow. I’ve found it in line 52 of the same example content-image.php but am hesitant to modify it and mess up the theme.
<span class="entry-format"><a href="<?php echo esc_url( get_post_format_link( 'image' ) ); ?>" title="<?php echo esc_attr( sprintf( __( 'All %s posts', 'ryu' ), get_post_format_string( 'image' ) ) ); ?>"><?php echo get_post_format_string( 'image' ); ?></a></span>
I have a feeling it’s not something I can copy and paste, but instead use certain variables within the syntax of the entry header, but I just plain don’t know how to PHP 😉
Is there a “post formats” list to use in PHP, and how can I swap the categories list for post formats?
- The topic ‘Replace "categories-links" with "post_format" links above post titles?’ is closed to new replies.