is_page(id) not working for blog page

If the page you’re trying to check is set as Page for posts, then is_page conditional won’t be true. In such case you should check if is_home. Why? All these conditional tags are based on global wp_query. For page that is set as page for posts (home of your blog), the global query doesn’t contain … Read more

Why aren’t my posts showing?

This doesn’t work the way you think it does because get_pages doesn’t do what you think it does. First, understand that all pages, all content, in WordPress is really a “post”. A “Page” is just a special type of post. Now, in a normal environment, you wouldn’t call “get_” anything. This is why you’re confused, … Read more

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 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