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?
- Permanently remove first image from posts
- how to display active, upcoming and past event with featured listing with pagination
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- Go to / Scroll to Password Field on WordPress Posts After Submit With Message(s)
- New Plugin Review
- Use template for posts with a particular category grandparent
- Include a specific post to the query_posts and remove it if it is already in the returned list
- Styling images coming from another blog
- “before delete post” action fire when the post is updated?
- Automatically add custom CSS to new posts using a category template
- Query all posts of a custom taxonomy term
- Retrieving Author ID in wp-admin area
- Can’t get wp_insert_post to work
- Why not yield/iterable in posts interface?
- Best practice for migration friendly images in posts/pages?
- 200 Rewrite blog post links
- Loop through categories and display posts title under each dropdown
- 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
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- Sort by page information by Ascending Numbers
- I restricted wordpress by logged users. It’s possible exclude a page?
- retrieve post data and insert it in seperate static html page without WordPress
- 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
- Function works everywhere, how to keep it to execute when creating a new post
- WordPress query undefined offset in loop
- Find Site ID From WP_Post
- WP_Query: getting posts where custom field exists
- change the default order of posts only for specific categories
- Reading settings in the home page precisely home.php
- get post id from wp_insert_post for get_template_part
- Displaying list of posts in category page
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Displaying content on posts page based on category
- how to make an array of post id’s in is_single
- Loading Posts & Category with Ajax
- Amend theme php to include certain category in header
- array_rand not working correctly?
- WP_Query() load selected post
- Unable to render custom field after attempt to generate a list of recent post in page template
- how to edit a specific post slug using a php code?
- How to pick “full/thumbnail” images in the loop?
- Why when I create a new post I found 2 record related to this post into the posts database table?
- Limit the number of child pages
- Prevent post from being published and show error
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Pagination at category doesnt work with same name of page
- understand what code is doing when prepending /blog
- My worpress search page is showing no results
- duplicate posts with ajax load more wordpress
- WordPress create custom XML RSS feed template
- How to display 8 posts in four columns and 2 rows on a carousel slide?
- Time Stamp In A WordPress Post Title That Does Not Keep Refreshing
- Menu not updating for logged in users after redirect
- Show a text if the post has written by author user role in WordPress
- Getting info about selected posts using one WP_Query
- Change upload URL by mime type
- How to pull date/time in french format for wordpress post?
- How to display last whole post on the homepage
- Make sticky post with FacetWP
- WordPress Single Post Pagination Numbered and Navigational
- Getting page / post URL on publish and / or update
- Let user select the number of posts shown per page jquery error
- Add wp posts to cutom masonry grid
- Displaying 3 Category Posts differently
- ‘posts_per_page’ in costum page type
- Weird Behaviour: Not all WordPress Posts appearing
- Dynamic form variables for post meta
- List of child pages fetch next results at link click
- Adding category in wordpress – custom
- How to display html code on homepage
- How to exclude post from being queried based on custom meta value
- Query category-specific, paginated posts and allow viewer to change sort order
- Auto create description in post
- Different image and background color depending on page type
- Custom query_posts() parameter
- Posts sortable column not sorting properly for custom field numbers
- HOW TO Insert Existing PHP Code to WOrdPress
- How to list all the posts in a personalized page? WordPress
- Set post to draft if matching word is found in the post
- How to create a WordPress PAGE in another folder?
- How do I get a function to work in single.php
- Count the number of matching post names in foreach loop
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)