• Hi guys, I’ve been spending my spare time creating my own theme using post formats and have run in to a couple of problems. You can see the site here:

    https://peterclaridge.me

    Problem #1

    How do you display all the posts with the ‘standard’ post format?

    I’ve used this link code to display all posts with the ‘images’ post format:

    <?php echo get_post_format_link('images'); ?>

    And it links correctly to this page:

    https://peterclaridge.me/type/image

    However if I try using:

    <?php echo get_post_format_link('standard'); ?>

    The link doesn’t go to the ‘standard’ format type link

    *****

    Problem #2

    Still related to the post formats and the ‘standard’ format issue. In the footer of my site I’ve got a list of Recent Posts and Popular Posts. Next to each one I want to display the correct post format icon.

    Initially I tried to use some If statements to show the correct post icon, and that worked for everything except the ‘standard’ post format, the code is given here:

    https://pastebin.com/BzRgBa7c

    (On a side note, I think it would be better to use a PHP Switch function instead of having all these if statements? I’m not sure how to do that though)

    How can I get the article post icon to show up for ‘standard’ post format blog posts?

    *****

    Problem #3

    How can I get the category ID of the post when the information is displayed outside the main loop?

    To the right of each blog post I have created a section called ‘More From This Category’ and I want to list 3 random posts from the same category as the individual blog post.

    At the moment I have simply hardcoded a random category ID so it will pull posts even if it’s from a different category to the blog post.

    https://pastebin.com/kg64ZgpJ

    Basically where it says [cat=5] I want it to be [cat=*category ID of the individual blog post*]

    *****

    Any help you can provide would be really appreciated, I’ve spent weeks working on this theme and learning all the in’s and out’s of building a wordpress theme but these three little things are still causing me problems!

    Thanks,

    Peter

Viewing 2 replies - 1 through 2 (of 2 total)
  • re 3:

    edited section:

    <?php $related = new WP_Query(); ?>
    <?php global $post; $cats = implode(',',wp_get_post_categories($post->ID)); ?>
    <?php $related->query('cat='.$cats.'&showposts=3&orderby=rand'); ?>

    https://codex.www.ads-software.com/Function_Reference/wp_get_post_categories
    (untested)

    Thread Starter aceriker

    (@aceriker)

    Thanks! I never would have got that by myself. Now just need someone who’s an expert in the post types ??

    I’ve got half a mind to simply add a new post type in the functions.php file and use that instead.

    add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image','video','articles' ) );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Formats Help’ is closed to new replies.