56

If by 'blog page' you meant a static page set as posts page in the Reading Settings, then you could check it by doing this: if ( is_front_page() && is_home() ) { // Default homepage } elseif ( is_front_page() ) { // static homepage } elseif ( is_home() ) { // blog page } else { //everyting else } When you use is_home() and is_front_page(),...


24

You can use the following in your themes functions.php file: function is_blog () { return ( is_archive() || is_author() || is_category() || is_home() || is_single() || is_tag()) && 'post' == get_post_type(); } And then put this in the file you are checking: <?php if (is_blog()) { echo 'You are on a blog page'; } ?> You can use Hooks in ...


16

If by 'blog page' you meant a static page set as posts page in the Reading: global $wp_query; if ( isset( $wp_query ) && (bool) $wp_query->is_posts_page ) { //static blog page } PS. This solution also works on template_redirect action


15

In WordPress 4.2 the editor was removed on whichever page was assigned to show Latest Posts for whatever reason. The following function below ( original solution found here by crgeary ) will re-add the editor and remove the notification: You are currently editing the page that shows your latest posts. Here's some information on the hooks used: ...


12

Don't forget that Wordpress was primarily designed to be a blogging CMS, so when it comes to theme development, developers often opt for a non-standard approach in exchange for the potential for more features. Theme developers have three options when they approach this, one of which (#2 below) you mentioned. Directly edit the index.php to modify the blog ...


9

It's been a while, but I came across this topic while looking for a way to enable gutenberg editor on the Blog Page. Didn't find any clue in google, so I dived into wordpress code and found the solution. Here is the code: add_filter( 'replace_editor', 'enable_gutenberg_editor_for_blog_page', 10, 2 ); /** * Simulate non-empty content to enable Gutenberg ...


6

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, because you're directly getting things and ...


6

The argument isn't category, it is cat. Your query fails because you are using an argument that doesn't exist. $args = array( 'post_type' => 'post' , 'orderby' => 'date' , 'order' => 'DESC' , 'posts_per_page' => 6, 'cat' => '3', 'paged' => get_query_var('paged'), 'post_parent' => $parent ); $q = new WP_Query($...


5

Use the following for with Custom Text with Link. The above given code by @TheDeadMedic works only with text but no link. Code With Link and Custom Text like this: <?php previous_post_link( '%link','Previous Post' ) ?> <?php next_post_link( '%link','Next Post' ) ?> Hope this helps.


5

Get First Five Posts With Specific Category <?php // the query $the_query = new WP_Query(array( 'category_name' => 'post_category_name', 'post_status' => 'publish', 'posts_per_page' => 5, )); ?> <?php if ($the_query->have_posts()) : ?> <?php ...


3

To get the blog index page, I found that if ( !is_front_page() && is_home() ) { // blog page } is not working for me, I had to use the get_option('page_for_posts') function to identify the Blog Page post_id, my answer is if ( !is_front_page() && is_home() ){ if ( empty ( $post_id) ) { global $post; $post_id = ...


2

I would personally do this rather. Instead of: 'category' => '3', Replace it with this: 'category_name' => 'my-category-slug' Obviously find the name of your category slug and replace 'my-category-slug'. As mentioned by @s-ha-dum it would be better to not use this method and rather use WP_Query method. You can see it in the WordPress Codex here: ...


2

You say you copied the entire content of index.php into home.php but I assume you have made some changes? Because if not the pages looks identical so maybe it is loading, but just the same? Now are you having posts or pages you want to display on your front page? Because for the posts and pages there is different hierarchy (from left the first template that ...


2

Use the WordPress Reading settings for your posts page named blog and create a static front-page.php file for your front page in your theme.


2

In your template where you see the_title(), you will want to change it to something along the following: echo get_the_title() . ', ' . 'posted by ' . get_the_author() . ', ' . human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . ' ago'; human_time_diff() is the one doing the part regarding your topic. Though you also ...


2

Before I start, I would recommend that you read: Creating a Static Front Page OK, when you select a static front page, one of the following templates are used to display the front page front-page.php page.php any other custom page template This is the part that you already have working from what I can understand from your question Now, the blog page. ...


2

You might use the wp_head action, That is triggered within the section of the user's template by the wp_head() function. add_action("wp_head", "hook_js"); function hook_js() { if(is_home() || is_front_page(){ $output="<script> alert('Page is loading...'); </script>"; echo $output; } } Note that is better to add style and ...


2

Problem solved . as i was making my custom theme from scratch so there was not content.php file included in my custom theme that displays the posts titles and contents i have added that. and it can also be solved if u add this line in you index.php page. the_content(); or the_title(); whatever u need. it can be like this in the while loop : while ( ...


2

you can add the lang parameter to your loop arguments like so $loop = new WP_Query( array ( 'post_type' => 'post', 'lang' => pll_current_language('slug'), //returns 'en' for example 'posts_per_page' => 10, 'post_status' => 'publish', ) ); However this is not the better practice because by ...


2

Use WP_Query for getting the posts you want. Then you can loop through them and get their title, their featured image and their excerpt to be printed they way you want. Something like that: <?php $args = [ 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 9, 'order' => 'DESC', 'orderby'...


2

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 singular page - it contains list of blog posts.


2

The conditional is_page is mapped to the is_page method of the wp_query class. As you can see in the source a couple of things are tested. First if the method does not apply to the object that is passed (for instance because it is not a wp_query instance), it returns false. Then the queried object is retrieved. This gets either the data for a page/post or, ...


2

Choose 'your latest posts' as to what your homepage should show. This will then show your latest posts on the homepage (aka your blog). Edit: looks like you have this working now!


1

You will need to edit your front-page template and before (or after) your loop, you need to make a call to get_post() so load your custom page. See the documentation for details. You can then render your customisable page on the homepage. For example, if your special page ID is 42: <?php $custom_page = get_post(42); echo apply_filters('...


1

your title tag is inside the script tag. It must be placed outside script. So you have to close the script tag for "adsbygoogle".


1

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', ...


1

You may edit the query using the pre_get_posts action. You can do something like this: add_action('pre_get_posts','wpse_218948_search_filter'); function wpse_218948_search_filter(){ if( is_page('blog') /* or whatever page it is */ && $query->is_main_query() ){ $query->set('post_type', 'blog'); # query post type "blog" $query-&...


1

Since it sounds like you're trying to do this without code I would do it this way: Create an 'Advertisement' post type which supports categories. Then use a 'Related Posts' widget that allows you to select custom post types as well as related categories. Possibly one of these And use the widget settings to call the appropriate Ad UPDATE: Not sure how clear ...


1

First check your template or source code to find the classes added to the article as a whole (or any html element that wraps around the whole post. It probably looks a bit like this: <article class="my-article"> <title class="my-title">TITLE</title> <img src="..." class="my-featured-image"/> <div class="my-content"> POST TEXT &...


1

Technically you don't need to include a posts page on your site. Plenty of sites consist of just some pages and no posts at all. However, Google uses the posts pages to find links to your individual posts. If there is no such page you will need a different structure to guide Google (for instance through the menu, by including a dropdown of your child ...


Only top voted, non community-wiki answers of a minimum length are eligible