Perhaps you can add the category to this line:
$lastposts = get_posts('numberposts=-1&category=7');
Replacing 7 with whatever category ID you need to use.
Link to the WordPress Codex page get_posts()
– Parameters.
Related Posts:
- How can I get posts in a subcategory to display on it’s parent categories archive page?
- Archive Listings Filtered by Date Values in a Custom Field/Post Meta?
- How to translate month names in “Archives”
- Custom Taxonomy Archive not displaying entries
- Query post for ‘selected category’ in archive.php
- Archive subtitles for different types of archives
- Show title bar only on archives / hide it on all posts and pages
- WordPress archive index page
- Custom Tags Archive – permalinks not working
- Make tag archive display post are ordered by post format
- Woocommerce custom archive page custom content and shortcode
- Can I overwrite custom taxonomy FROM “public” TO “false”
- How Can I add show_post_count in get_archives_link?
- Multiple posts categorized by day?
- How do register_sidebar() and get_sidebar() work together?
- Version Control: Entire site or just pieces?
- Getting a stack trace when an error occurs?
- Setting up custom post type archives in WP3.1? Any luck?
- Multiple WordPress sites with docker
- .maintenance and maintenance.php also in multisite install?
- how to redirect to a custom password retrieval page
- Is there a plugin to make attaching images easier?
- Custom category order with get_categories
- Pagination Help on Crazy Custom Authors Page
- Getting rid of the #038; when string replacing content
- Querying multiple WordPress custom fields with AND qualifier
- WordPress custom post types breaks permalink on theme reinstall
- page_template toggle between 2 templates + 2 permalinks for same post
- Create a Custom menu item fetched by Product Categories and Sub Categories
- Multi-Site Plugin Activated (Not Network-Activated), What Happens?
- How could we customize the all posts page in the admin panel?
- How do I perform a “get” call to an external API, and then display the JSON results on a page in my WordPress site?
- How to build a child theme from a react-based parent theme?
- How can I get the page url slug when ‘post_name’ returns an id?
- Woocommerce Product page edit
- Convert an theme options page to use in customize.php also?
- Adding action to save_post, post needs to be saved twice for function to work
- The best way to write an FAQ page?
- 1 bit audio player
- Outputting posts from post id´s in variable
- Get Value from Column in Plugin Table [closed]
- The Best Way to always load the newest version of 3rd party code
- Theme licensing and permission on changing content [closed]
- Add ‘Creator’ User Meta when adding user
- Auto login after wordpress installation
- Using Fullscreenr with a wordpress blog – weird bug
- Determining What Content Gets Displayed
- Truncating varying lengths of information
- How to get pages id in array in get_pages?
- Access post meta in future_to_publish function
- Javascript Solution Remove Specific Tag but leave the rest in a specific DIV
- Display User ID instead of Name or Username
- woocommerce_checkout_fields modifying existing billing_phone label created new field
- Bind JS event to WordPress control customizer
- Edit sticky header html – How to locate corresponding php file
- custom meta box for page default template
- OrderBy multiple custom meta fields
- How to host 2 subdomains as lookalike destinations under one master domain?
- Track usernames with piwik [closed]
- “An automated WordPress update has failed to complete – please attempt the update again now”– But there is no .maintenance file
- Custom Login Process
- How could I verify whole WP directory before/after working with a freelancer? [closed]
- Modify files without losing customization after updates
- Woocommerce – Print Product’s Custom Field In Email
- Applying WP-cli Search & Replace to Static SQL Dump File
- How to unpixelate logo?
- Create a Page template selector page
- How to add functionality to an existing theme (using child themes)
- How do I fix my static page
- URL and Site title outputting on Login page
- List of contents of entire blog
- optimal taxonomy or custom post types
- Easily add custom HTML outside the main container?
- How do I make mysite.com/comingsoon WordPress to become my main website’s WordPress?
- adding fade on mouseover to images
- Customize section does not show my widget areas
- Invitation link to a site in multisite network does not work?
- Lightbox not showing image caption
- WordPress core jquery version file not loaded?
- Can we add an extra button on woocommerce shop page and use it to send the product info including image in a mail?
- Make Widget appear on Dashboard
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- Woocommerce dependent attributes
- clickable toggle menu, help
- twenty seventeen customizer duplicates section content
- How to append the excerpt to the content in the single post page?
- How to Password Protect whole site except for some subdirectories
- Displaying all Custom fields on post except some
- WordPress Install – “end of script output before headers” when running simple php script
- Ordering a specific post type
- How to replace part of shortlink with nothing
- Header image doesn’t show up on page
- Is there a way to hide a user’s posts from their Activity feed?
- Setting up staging area
- Assign classes to Custom fields
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Do i need to use PHP in customizer api?
- Add variable : 1 Week ago
- When is it OK to create a custom table for a plugin? [duplicate]
- Prevent posts from being published if the ‘Uncategorized’-category or no category is selected