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
- Creating bulk posts with Youtube videos
- Archive Page for Custom Post Type is not Working
- Accessing post->ID outside of the loop for listing child pages
- Animated gif for a thumbs
- Sidebar links for different pages
- Posts vs. Pages
- how to set beforsend option in wordpress ajax methods
- Dynamic carousel on individual posts
- Blog Posts not showing title
- Filter Custom Post Type by Category with Ajax
- Hide wordpress field if data is empty in post!
- Edit custom post type admin menu link
- Remove certain post-formats from showing in blog?
- Deleted category by mistake, all posts now have categorized category. Can i revert that?
- How blog page in WordPress works : blog page retrieve first post ID
- I am unable to publish/update post
- How to display data in archive page?
- Delete post by giving its link
- How to add pagination in between post and comments?
- How to include a post type in the admin/backend?
- Display post category in foreach loop with category link
- Set terms in a custom post
- Why is my Blog Page ID == First Post ID?
- Get posts of ONE taxonomy term of custom post type
- Why WP_Query(‘showposts=5’) shows only 1 post?
- I want to display custom text widgets for each post in the sidebar?
- Most liked page not displaying posts
- Displaying Latest Posts on a Page
- Add blogs to “Blogs i Follow” sidebar [closed]
- Display posts styled exactly like default posts
- WordPress blog or WordPress website
- How to make classes for posts?
- Using custom post template
- Choose whether to automatically add a taxonomy with the same name as the post
- Custom Post Archive Page not working
- How can i display gallery shortcode output under Post text
- Hiding Draft Post In Admin
- Display posts from a different website on Genesis Responsive Slider
- Print all the tags from a custom post type Please
- Display multiple custom taxonomy values on single custom post types page?
- WP Bakery Load More Button loads the same posts
- Adding custom fields to bbpress reply form
- Move first half of posts to one parent page, second half to the other page
- Adding buttons to Add New Post and Add New Page
- add new post default view
- Custom Post Type – Category Rewrite – Remove Rewrite from Sitemap
- CPT archive redirects to single post
- Show certain posts in a LIST format that members have been granted access to
- Show posts by a custom post author
- Custom loop pagination links not working
- Prevent Delete Attachment by URL or When Submit
- Enable Comments Box On Custom Post Type
- wp-cli post create & media import issues
- Append class to posts page
- How can i limit the number of posts created per category?
- Search results posts_orderby and ID
- Getting Custom Post Loop to display in Bootstrap 3 column grid
- Turn On Comments On Custom Post Types in Directory Theme
- WordPress custom Query for Posts in Category display posts multiple times
- Responsive images with custom image size
- Making a custom Pagination for multi page blog post
- ERROR: Your feed is invalid (after update WP4.7) in custom types
- Editing the default page to show all posts, rather than most recent ones
- Unable to restore from backup – how to obtain old blog posts?
- How to disable WordPress blog folder
- Automatically add date to the auto generation of post slug
- Loading index.php contents which located outside blog folder for post single page
- Permission issue with custom post type – not added to menu – by plugin
- Duplicate Custom Post Type and Taxonomy Slug
- Posting blog entries in screenplay format
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- Take a received feedback item, turn it into a post
- Getting value from get_post_custom
- WP Admin register taxonomy and post type performance
- Add a custom meta box in the post options that loads some html code in the header
- Static posts page with home.php
- Custom posts in different columns style
- Calling Different Custom Post Timestamps in a table
- WordPress Multisite – Create Default Post and New Category On New Site Install
- Admin – create custom post status and display above table
- Creating a post from data returned from HTML form
- custom post template file not shown, instead all the time 404.php
- Set Default Category to Username
- How to allow visitors to filter posts by multiple taxonomies
- show custom post type category dropdown sorting result on same page
- List authors with the last post title and order by last post date
- Custom Post Type Rewrite To Include Parent Page(s)
- Thumbnail & Category link aside post
- Redirect to another page using contact form 7? [closed]
- Display post category in foreach loop