Alright, I think I found my answer.
As I’ve said, I created a new php template in my theme named “New Index” and associated my homepage to it.
This template was at first a copy of the original index.php
Now here is the code I added for it to make what I wanted :
<?php $the_query = new WP_Query( 'posts_per_page=1&category_name=news' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<div id="last_news">
<div id="last_news_title"><?php the_title(); ?></div>
<div id="last_news_time"><?php the_time('j F Y'); ?></div>
<div id="last_news_content"><?php the_content(); ?></div>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
This may not be the optimal solution though, I’d be curious to hear tips about it.
Related Posts:
- Alter query on edit.php
- Exclude posts from homepage having a specified tag
- Counting Search results, and displaying the offset per page
- Pagination broken on is_front_page()
- show recent posts php code error?
- Saving a post ID to use in a form elsewhere on website
- WordPress sorting posts by date and title using a dropdown
- Is there anyway I can call the year once?
- Having trouble with customizing blog posts on the home page
- Insert div after every three posts in home.php [duplicate]
- Automatically create a loop for post ID
- How to modify this function to exclude also the post belonging to a specific category?
- Category Attachment Pagination 404 Error on 2nd Page
- Using loop pagination on single.php
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Logged in user ID as post ID
- Sort query_posts for Parent Pages to menue order or the count?
- Unreadable pagination
- 200 Rewrite blog post links
- How to set a min number of words for a blog post
- Loop through categories and display posts title under each dropdown
- Get post id in a function when edit/add a post
- how do I get a specific post from a post with a subcategory in WP
- Automatically create child pages and grandchild pages when saving a (parent) page
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Second transition_post_status hook fired instead of the first
- How to store post ID’s in cookie or session to display the same posts later
- Which hook/action will help me solve my problem?
- How can I add extra word in permalink when someone click download button?
- Post + form + action + results on the same page
- Open post-content in archive page in a Modal box with bootstrap
- Let Users Choose Post Categories
- remove post that has no content
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- Post repeating with infinite scroll
- Custom posts in different columns style
- Get children post mime type using parent post_ID wp_post
- How to show only subcategories in parent category not parent category?
- two columns of posts on homepage, one of them “favorites”
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- 404 error when I acess the second page of post-type
- Sort by page information by Ascending Numbers
- I restricted wordpress by logged users. It’s possible exclude a page?
- Which PHP page is the Default Posts Page
- retrieve post data and insert it in seperate static html page without WordPress
- WP Insert Post and then go to post
- How to list posts from a plugin taxonomy?
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Returning data instead of echoing/printing
- Display related posts without a plugin
- How to get post ID in a Page?
- Count posts on multisite with blog id
- Function works everywhere, how to keep it to execute when creating a new post
- Making (and edit existing) posts with ID included
- Copy taxonomy terms from one post to another programmatically
- Parsing Menu Items and Blog Posts
- Pagination on Custom Post
- $wpdb returns duplicate posts
- How to avoid duplicates when creating recent network posts
- How to show an entire post content and not also the excerpt?
- Get latest post from all categories except one
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Update post title from external file?
- Parse error: syntax error, unexpected end of file
- How to include custom code on a page that’s set to act as homepage?
- Automatically add images to a menu
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Load Posts on Click via Ajax into a DIV
- How to catch wordpress post ID when it’s published
- set post limit at load more ajax wordpress
- WordPress query undefined offset in loop
- Find Site ID From WP_Post
- WP_Query: getting posts where custom field exists
- Array to string conversion on array_map
- Store metakey value as an array
- Increment paged on WP_Query
- Only show first image in foreach loop
- change the default order of posts only for specific categories
- How to use mysql LIKE with wpdb?
- Reading settings in the home page precisely home.php
- Do I need to edit my theme in order to change the title of my blog page?
- Add new post in existing categories using wp_insert_post
- WordPress upload file size error even after raising php limits
- How do I add more options to the post-new.php page?
- get post id from wp_insert_post for get_template_part
- create front-end users post list by specific category
- Incrementing PHP variable onclick to display posts by month
- Modify main query before it run without pre_get_post
- Displaying list of posts in category page
- .html end of URl affected to SEO?
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Get the id of all images in a post
- Displaying content on posts page based on category
- Do not duplicate posts with multiple categories in multiple loops
- how to make an array of post id’s in is_single
- Posts are not looping through correctly
- Loading Posts & Category with Ajax
- Four posts per row [closed]