Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other [WordPress] custom post design per category

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #158917
    mvaneijgen
    Participant

    I’m busy designing a blog and what i like to have is a custom structure for certain post categories at the ‘blog post overview page’. I’m not a WordPress developer hero, but i like to mess with the code till i can wrap my head around it, but for this i don’t know where to start.

    Down here i provided a screenshot of what it could look like. If i have to explain it in text: If the post category is Portfolio show the a large featured image with the title in it and hide the rest of the content.

    I know i have to a lot of this with CSS but how do i loop through all the post and get the elements i want and for other categories don’t get those elements?

    Screenshot:

    I was thinking to just load every element for every post and then hide them for certain categories, but i thought that was kind of dirty.

    I hope i explaind my self well and someone can point me to some good resources.

    #158924
    mvaneijgen
    Participant

    This is how far i have come

    if(query_posts('cat=5')) {
    $count = 0;
        while ( have_posts() ) { the_post();
    
            get_template_part( 'content-portfolio', get_post_format() );
        } // End WHILE Loop
    
    } else { 
    
    
    if ( have_posts() ) {
        $count = 0;
            while ( have_posts() ) { the_post(); $count++;
    
                /* Include the Post-Format-specific template for the content.
                * If you want to overload this in a child theme then include a file
                * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                */
                get_template_part( 'content-blog', get_post_format() );
    
            } // End WHILE Loop
    
     } else {
        ?>
            <article <?php post_class(); ?>>
                <p><?php _e( 'Sorry, no posts matched your criteria.', 'woothemes' ); ?></p>
            </article><!-- /.post -->
        <?php } // End IF Statement ?
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.