Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter jay_wp

    (@jay_wp)

    It’s incredible to see how powerful CSS can be! I tried :first-child and :nth-child selectors (selecting .post then the article element as an alternative), and it seems to be working like a charm! Not sure if this method might cause any problems down the road (other than the older browsers issue) but I think I will go with this option. Thank you all for your guidance.

    Thread Starter jay_wp

    (@jay_wp)

    @trisham, thanks for your response. CSS :first-child selector may work for the first post but how about the three or four posts following that first one? They are all on the home/front page but the very first (most recent) post and the other group of three or four will have different styles.

    Thread Starter jay_wp

    (@jay_wp)

    Following from my post above, I guess I should also ask why the CSS approach would not be possible. I’m guessing it’s related to the dynamic nature of the platform and not being able to select the latest post (and few earlier ones) through HTML structure of the theme.

    As per your advice, I changed my index.php page as below. Does it look ok? Thanks a lot again for your help.

    <div id="primary" class="content-area">
    		<div id="content" class="site-content" role="main">
    		<?php if ( have_posts() ) {
    			 while ( have_posts() ) {
    			    the_post();
    			    if( $wp_query->current_post == 0 ){
    			        get_template_part( 'content', 'style1' ); //loading content-style1.php file
    			    }
    				elseif( $wp_query->current_post > 0 && $wp_query->current_post < 4 ){
    			        get_template_part( 'content', 'style2' ); //loading content-style2.php file
    			    }
    				else{
    			        get_template_part( 'content', get_post_format() );
    			    }
    			    $wp_query->current_post++;
    			    }
    			    twentythirteen_paging_nav();
    				}
    				else{
    			    get_template_part( 'content', 'none' );
    				}
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    Thread Starter jay_wp

    (@jay_wp)

    Hi again, while I try to implement the solutions suggested, I’ve wondered why this cannot be done simply with CSS. Not sure if and how this is possible but I’m just wondering if there is a way to select the first post and the next three (or four) posts on the home/front page and style them on the style.css. Is this possible? What do you think? Thanks.

    Thread Starter jay_wp

    (@jay_wp)

    @ghanshyam, thanks for your clear response. I will give it a try later today.

    @wp Gurus, thanks for the short cut. I can try it especially for learning purposes but I couldn’t get my head around how I can check the value of $wp_query->current_post in Ghanshyam’s code? Where exactly in his code should I place that?

    Forum: Fixing WordPress
    In reply to: Thank You page
    Thread Starter jay_wp

    (@jay_wp)

    Huh, thanks suziwilson. I just created a custom menu which seems to be the perfect and simple solution to a problem that created long threads of posts in the forum. I wonder why no one offered this method before.

Viewing 6 replies - 1 through 6 (of 6 total)