ID of Front-Page

This should do the trick. global $wp_query; $post = $wp_query->get_queried_object(); $post->ID; This’ll give you the ID for each page you’re on. get_option( ‘page_on_front’ ) should’ve worked though.

How to Display a Plugin function (content) on frontpage using index.php

Your plugin inserts its feelbox widget by filtering the_content: if ($options[‘showinpostsondefault’] == ‘on’) { add_filter(‘the_content’, ‘add_feelbox_widget_to_posts’); } But your index page doesn’t display the_content, just Title, featured thumbnail, an excerpt and, number of comments. The plugin code you’ve shown us doesn’t include a print_feelbox_widget() function. Does such a function actually exist in your plugin? (Also, … Read more

Displaying recent post excerpts on static front page

I’ve found the solution. According to https://codex.wordpress.org/Function_Reference/the_content#Overriding_Archive.2FSingle_Page_Behavior, one must add global $more; $more = 0; before the call to the_content(). So now my inner loop reads: <?php $recent_posts_query = new WP_Query(array(‘post_type’ => ‘post’, ‘posts_per_page’ => 5)); while ($recent_posts_query->have_posts()) { $recent_posts_query->the_post(); ?> <div class=”post”> <h3><?php echo the_title(); ?></h3> <p>by <?php the_author(); ?></p> <?php global $more; $more … Read more

Loop first six posts in carousel, next eight in grid

Use WP_Query with offset like this <?php $offset = 6; $post_args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => $offset, ); $slider_blog_posts = new WP_Query( $post_args ); ?> <?php if ( $slider_blog_posts->have_posts() ): ?> <div class=”carousel”> <?php while( $slider_blog_posts->have_posts() ): $slider_blog_posts->the_post(); ?> <?php get_carousel_slide( get_the_ID, true); ?> <?php endwhile; ?> </div> <?php endif; ?> <?php wp_reset_postdata(); … Read more

What does choosing a Post Page do?

Why will choosing a “Post page” be useful? Because if your homepage is a static page, where will the main post archive go? It no longer exists, but you can bring it back by choosing a posts page. You do this by choosing a page that has the URL you want, and that URL wll … Read more

Arrange posts by date in front page

Add orderby and order to your arguments: $cat_query = new WP_Query( array( ‘post__not_in’ => get_option( ‘sticky_posts’ ), ‘category__in’ => array($cat->term_id), ‘posts_per_page’ => 5, ‘paged’ => $paged, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) ); Update it seems it still takes one category, lists 5 posts and then goes to another, with 5 posts etc. It … Read more