Change “posts per page” depending on width

A simple approach would be a solution with CSS and PHP. <?php $postcount = 1; $wp_query = new WP_Query(); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div class=”post-<?php echo $postcount ?>”> <h3><a href=”https://wordpress.stackexchange.com/questions/111019/<?php the_permalink() ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></h3> <div class=”entry”> <?php the_excerpt(); ?> </div> </div> <?php $postcount++; endwhile; ?> Then you can style your website, … Read more

two active templates for one post

If you look at the function you’ll see there’s an error : function detail_rewrite_rule( $rules ) { $newrules = array(); $newrules[‘(.+?)/([^/]+)(/[0-9]+)?/detail/?$’] = ‘index.php?category_name=$matches[1]&name=$matches[2]&page=$matches[3]&detail=1’; return $newrules + $rules; } add_filter( ‘rewrite_rules_array’,’detail_rewrite_rules’ ); The callback is not the same : detail_rewrite_rule, detail_rewrite_rules. In the add_filter you have to provide the same name for function. Otherwise this won’t … Read more

excerpt not showing up

Inside a template file, the standard loop syntax will display only the information about that page( In fact, a template file is no more than a page ). If you want to display some posts you need to run a custom query or to include ( get_template_part() ) another template file which normally runs a … Read more

Category link redirect to custom template page instead of index.php?

Your question implies that index.php is a page to be redirected to, it isn’t, it’s purely a template file. It implies that single.php being loaded is what makes a page singular, or that loading the page.php template will give you a page, when it’s actually the other way around. I strongly recommend reading about the … Read more