WordPress.org

Ready to get started?Download WordPress

Forums

Magazine Basic
Index page incorrect div tags (2 posts)

  1. konigrot
    Member
    Posted 1 year ago #

    I noticed that the div tags on the index.php had incorrect open/close div matchups depending on the number of posts (0 vs more say). On checking the file I noticed the code below. The $two_open_tag and $three_open_tag variables are empty or contain html dependent on other variables, but for some reason there is some crazy ass complicated code to decide whether to add the close divs. I might be mistaken, but I changed the lines to add the close tags if the corresponding open tags contain a non-empty string. I suspect the borked matchup only happens in rare cases when there are no posts or something, but I thought I'd mention it.

    SEE BELOW (mods marked BH)

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <?php
    			while ( have_posts() ) : the_post();
    				global $wp_query;
    				$paged = ( get_query_var( 'paged' ) ) ? get_query_var('paged') : 1;
    				$grid = mb_theme_options( 'grid' );
    				$posts_per_page = mb_theme_options( 'number' );
    				$count = $wp_query->current_post;
    				$total = $wp_query->post_count - 1;
    				$border = ( 3 == $grid && 1 == $paged ) ? '<div class="c12 border"><span></span></div>' : '';
    				$two_open_tag = ( ( ( 2 == $grid || 3 == $grid) && 1 == $count && 1 == $paged ) || ( 2 == $grid && 0 == $count && 1 < $paged ) ) ? '<div class="two-col-wrapper">' : '';
    				//BH drop fancy conditionals - just close div if open tag string > 0
    				//$two_close_tag = ( ( 2 == $grid && $total == $count ) || ( 3 == $grid && 2 == $count && 1 == $paged ) ) ? '</div>' : '';
    				$two_close_tag =  count($two_open_tag)? '</div>' : '';
    				$three_open_tag = ( ( 3 == $grid  && 3 == $count && 1 == $paged ) || ( 4 == $grid  && 1 == $count && 1 == $paged ) || ( ( 3 == $grid || 4 == $grid ) && 0 == $count && 1 < $paged ) ) ? $border . '<div class="three-col-wrapper">' : '';
    //BH same again - drop the fancy conditional
    				//$three_close_tag = ( ( 3 == $grid || 4 == $grid ) && $total == $count ) ? '</div>' : '';
    				$three_close_tag = count($three_open_tag) ? $border . '<div class="three-col-wrapper">' : '';
    				if ( 1 < $posts_per_page ) {
    					echo $two_open_tag;
    					echo $three_open_tag;
    				}
    		    	global $mb_content_area;
    		    	$mb_content_area = 'main';
    		    	get_template_part( 'content', get_post_format() );
    				if ( 1 < $posts_per_page ) {
    					echo $two_close_tag;
    					echo $three_close_tag;
    				}
    			endwhile;
    			?>
  2. c.bavota
    Member
    Theme Author

    Posted 1 year ago #

    This should be fixed in the next release.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic