It might actually still work, but the syntax is currently wrong (you have a PHP opening tag inside another opening tag). And you can assign the value of the custom field to a variable using the get_field
function. What if you try this?
<?php
// assuming your ACF name is 'number_of_posts'
$numposts = get_field('number_of_posts');
$args = array( 'numberposts' => $numposts );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post);
?>
Related Posts:
- Blog Posts in Custom Menu
- WordPress Custom Fields (Checkboxes with multiple values)
- How could I change my Permalink from blog to custom structure? [closed]
- WordPress Query Posts From Category Post on Static Page
- How to display only one category in a custom post type?
- My posts page is missing the page title
- How can I have the posts from one word press blog show on the presentation page of another word press site
- Show a Category Specific Info Box
- How can i retrive the movies, trailers, news in a single page using search
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- Where does WordPress store the users customization in the theme
- Add a checkbox to post screen that adds a class to the title
- delete post also attachments
- Publish pending article from front end with a button?
- Attach pdf file to custom post type
- How do I create a featured post within a custom post type?
- How do I convert a mathematical Microsoft Word document to a WordPress blog post?
- How to edit wordpress RSS feed to show post title only
- Add custom field to category of custom post type
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- user contributed content as custom post types
- Remove custom posts that match taxonomy value
- Advanced Custom Fields – Storing array value for further usage
- Custom Theme Want To Remove One Category From All Displays
- Post Type Label Name
- wp_query ‘s’ parameter does not work with custom post type
- Limit Gutenberg blocks available to users to choose from
- Accessing post->ID outside of the loop for listing child pages
- Remove certain post-formats from showing in blog?
- How to display data in archive page?
- I want to display custom text widgets for each post in the sidebar?
- Display posts styled exactly like default posts
- Choose whether to automatically add a taxonomy with the same name as the post
- Print all the tags from a custom post type Please
- Move first half of posts to one parent page, second half to the other page
- Enable Comments Box On Custom Post Type
- Append class to posts page
- How can i limit the number of posts created per category?
- Responsive images with custom image size
- Take a received feedback item, turn it into a post
- Admin – create custom post status and display above table
- Set Default Category to Username
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- Dynamically switch template on click
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- Page template is accessing the incorrect posts?
- Customize rel=canonical tag for single blog post
- disable Tab post on nav-menus page (Admin)
- Best Way to Add UnEditable HTML to Posts
- Get post meta retrieving wrong value
- How safe is it to delete old posts edits to save database space?
- Is codex right on deleting post?
- if in category but only with post meta
- How to get different Related Posts
- Update if post with specific title exists
- l accidentally permanently deleted a Draft. There’s any way I can recover it?
- Inserting an example of the last 3 post on to the homepage
- Get a term each custom post type
- Display message depending on capability outside loop
- Adjust the order for returned posts
- Getting post and attached image from subdomain
- Custom post type slideshow background images to insert in a plugin
- Help on conditional statement to accompany wp_insert_post function please?
- How to fix wordpress blog post error? Can anyone help to fix this issue?
- Search results for ACF data
- Redirect to custom post if custom archive page has just one result?
- Template for displaying CPT / Taxonomy URL issues
- Multiple posts in one page
- delete post hook not being fired when deling in wordpress dashboard admin
- WordPress Delete Users from backend doesn’t work
- Is it possible to make a custom post that adds multiple pages?
- Hiding title of selected post without plugins
- Custom post styling per category?
- Hook To Get All Posts Deleted
- Meta boxes not saving
- Custom URL Structure for posts with subcategories
- Hide first blog post in content and output it in widget
- How to show the posts list into a static page? Problems to use the loop into a static page
- How do I control the fallback query after the original query returned cero posts?
- Adding The Post Template Dropdown to WP-Admin
- Allow users to create their own page/s
- 404 for some custom taxonomy not ALL taxonomy
- new blog post does not appear in blog after publishing
- How can I create a menu items from meta box based on users input
- How do I display a full post, not just an excerpt?
- Add default content to post (for specific category)
- Wanting to apply different featured images for each post
- WordPress strips some attributes for author posts
- Automatically delete default posts and pages on theme install?
- How *not* to show the last post on the latest posts list
- How to Do Custom Fields to Output a Definition List
- Display one post randomly from category on home page
- Deleting first four characters from all Post Titles
- Deleling wordpress posts permanently still have IDs
- get value from post to sidebar
- Post only showing on homepage when Logged in – direct URL still working
- Post’s arent displaying
- Can I get custom post items in select box (dropdown)
- How to have 2 posting pages on a blog
- How to save the same post in multiple blogs?