Please check how the Loop works, followed by the correct way to instantiate a new Query.
Try this:
<?php
// The correct way to create a new Query
$newquery = new WP_Query( array(
'category_name' => 'notice',
'posts_per_page' => 1
));
// Check if query found posts, then start the Loop
if($newquery->have_posts) : while ($newquery->have_posts() ) : the_post();
echo '<h1><a href="'.get_the_permalink().'">'.get_the_title().'</a></h1>';
the_content();
// End post iteration
endwhile;
// If query didnt find any posts
else:
echo 'No posts in the query';
// End the Loop and reset the query
endif; wp_reset_query();
?>
If nothing shows up, you should debug the query with:
var_dump($newquery);
Related Posts:
- Add extra parameters after permalink?
- Change permalinks for posts but not for custom post types
- Custom permalink with pagination
- Custom permalinks – post type – hierarchical taxonomy’s
- Custom Taxonomy List links being re-written
- Wp-query causing problems with the_content();
- How to create posts (not post template) to be displayed on projects page?
- Add extra parameters after permalink?
- Quickest way to get last or oldest post date – WP Query
- How do I create an archive page for standard posts?
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Loop on front-page.php
- Automaticly add slug to posts
- How to post twitter like updates on wordpress
- WP_Query is printing out only one post when posts_per_page is set to multiple
- Blog page showing same content as homepage
- WordPress Orderby Numeric Value Not Working
- is there a way to retrieve posts that do not have a featured image assigned?
- How to add post_type=value when editing that post type in the WordPress admin?
- Storing posts from query and accessing later via AJAX call
- Show custom post type filtered by category
- Get latest 3 posts from multiple CPT in one query
- Add custom post type settings to wordress default posts
- Several post types on WP Query by tag and taxonomy
- How to have this permalink structure: post_type/postname/custom_inner_page
- Prioritize posts in query by meta keys?
- How to get all tags of a custom post type by id
- WP the_posts() on single-cars.php get category link
- Permalink misbehaving in Custom Post Types
- Check post on publish for blank title
- Different Limit number of post on different archive page
- Custom post types and ‘new WP_Query’
- Variable not working in WP_Query
- Display Only Certain Category In a Custom Page Template
- WP_Query with custom post type ID
- Query within a foreach within a query (queryception)
- How to implement a different permalink structure for custom post type?
- wordpress lists similar type of posts in a custom post type
- display posts of custom post type with custom taxonomy
- How to Query in WordPress which shows Alphabetic Posts?
- How to query Posts from a custom post type which contains a custom taxonomy?
- Display post from custom post type
- list posts of two post types in a single template
- How to fetch posts that are stored in the different table than (default) wp_posts?
- How to setup different permlalinks for posts and pages?
- Adding /blog in front of single posts (only)
- How to mass get post editor URLs
- Display Parent-Child Posts in specific order by comparing IDs in array
- add all blog posts to folder
- Permalink for specific post type
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- wp_post_delete is deleting all offices
- SEARCH QUERIES – REVERSE OUTPUT
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- How can I get custom post types to recognize pretty permalink variables?
- News post with multiple permalinks? When opened from different page
- minimize wp_query call to database
- Post display in separate page [duplicate]
- subtracting the current post form then whole loop, which is generating all CPT titles
- post type => ‘any’ not applied my custom queries
- Custom Post By Category
- Custom post Query and WordPress Post Query Clash
- How to get the posts that my following users are liked?
- Creating custom post type relationships
- Links Image in “Catalog” Page to Posts
- Get post from Category by Priority
- Most efficient way of showing children posts?
- Only show current category post
- How To Loop Through list with Custom Post Types
- Custom Post Type + Category archive
- Calling specific page with wp query
- Issue with permalinks for custom post type
- Custom Post Type permalink not working on new posts
- Retrieving IDs of child pages which are in a different post type
- Query Posts From Multiple Post Types
- Change display wp post type to wp custom post type
- Dynamically change post_parent in every page load?
- Change permalinks for posts but not custom post type?
- Add /blog to the “post” post type url
- Cannot exclude particular post from loop of custom post type
- How do I hide single category post on my post page
- show the most recent date of all posts to display on front end
- How to get permalink of post based on post name?
- Sort ACF by custom taxonomy
- How to assign a single-menu-template to a menu-items in a taxony/ cat/ subcat/ subcat-item
- WP_Query for multiple post types just shows one
- button onclick with get_post_permalink
- A developer set a ‘standard format’ for my blogposts on wordpress but i need to remove it, how?
- Unable to get paginate_links working with a custom query [duplicate]
- Different permalink for CPT and regular Posts/Pages but why?
- Get custom posts with certain ids in a custom loop using a shortcode
- Custom fields in Permalinks?
- Querying Term Posts in Loop
- How to use WP_Query in a CPT achive page?
- apply filters only to specific post listing without check the url parameters
- Use get_post_types to query only custom posts types
- How Can I Set the Post Author of a Post I Just Created With PHP?
- How do I fix permalinks for custom post types that has the same slug as a page?
- Custom post type and body_class: Remove “blog” class
- Custom Post Type Loop within Shortcode