How to get the list of posts in a static page other than front page?

The way I retrieve posts on my blog is to use the following: <?php $recentPosts = new WP_Query(); $recentPosts->query(‘showposts=5&cat=CAT_ID_GOES_HERE’); while($recentPosts->have_posts()): $recentPosts->the_post(); ?> Then you would go and create the code to control the display of each post. So for a really simple example: <h1 class=”title”><a href=”https://wordpress.stackexchange.com/questions/3170/<?php the_permalink(); ?>”><?php the_title(); ?></a></h1> Then at the end of … Read more

How to query ‘posts_per_page’ to display a different blog posts index template?

You can control what template loads for any type of query via the Template Filters. Here’s an example using home_template that checks if posts_per_page is equal to 1, and loads single.php in that case. function wpd_home_template( $home_template=”” ){ if( get_option( ‘posts_per_page’ ) == 1 ){ $home_template = locate_template( ‘single.php’, false ); } return $home_template; } … Read more

How to change the link structure of the homepage?

No need to change core files: add_action( ‘init’, ‘wpse316713_pagination_base_rewrite_rule’ ); function wpse316713_pagination_base_rewrite_rule() { global $wp_rewrite; $wp_rewrite->pagination_base=”image”; } Go to permalink options page, and press save to flush the rewrite rules, changes should apply afterwards.

How to change the permalink structure of a master page?

To remove pagination prefix page in home page you should: add a rewrite rule which will translate the new link format, prevent redirection to address containing page, replace URLs in paging links. By creating pagination links, WordPress appends query var paged with mentioned prefix to url. Therefore, without modification, the links would look like example.com/3/page/3. … Read more

Exclude category on blog list page

From a plugin or your theme’s functions.php file: function wpse106861_mod_query( $query ) { /* are we on the blog page ? */ if ( $query->is_home() && $query->is_main_query() ) { /* get ID of news category */ $news_id = get_cat_ID( ‘news’ ); /* exclude posts in new from query */ $query->set( ‘category__not_in’ => array( $news_id ) … Read more

Custom fields won’t display on my blog page

Try using: <?php // Determine context $page_id = ( ‘page’ == get_option( ‘show_on_front’ ) ? get_option( ‘page_for_posts’ ) : get_the_ID ); // Echo post meta for $page_id echo get_post_meta( $page_id, ‘Page Description’, true ); ?> What’s happening: You’re using a static page as front page, and a static page to display the blog posts index … Read more