WordPress.org

Ready to get started?Download WordPress

Forums

Get-Category-format (2 posts)

  1. javier68
    Member
    Posted 1 year ago #

    Hello everybody,

    I have this website (http://www.sergisirvent.miraquewebs.com/) and with this code, in the home page, it appear a box for every post:

    <?php

    $format = get_post_format();
    get_template_part( "formats/".$format );

    if($format == "")
    get_template_part( "formats/standard" );

    ?>

    I wanna make the same but for each category, I tried different ways (with if... for each post) but nothing worked. The only useful I got is this that if I put it in the loop it print the category names:

    $output .= '<div class="post" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px); opacity: 1; width: 270px;">term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</div>'.$separator;
    echo trim($output, $separator);

    Thanks a lot for your help,

    Javi

  2. javier68
    Member
    Posted 1 year ago #

    The code that makes print the post content is:

    <?php

    $format = get_post_format();
    get_template_part( "formats/".$format );

    if($format == "")
    get_template_part( "formats/standard" );

    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic