the_title
doesn’t work that way:
the_title( $before, $after, $echo );
$before
is the text that comes before the title, but you didn’t give it a string/text, you gave it a post object. Post objects aren’t strings, PHP doesn’t know what to do so it stops and prints an error instead.
For the_title
to work, you need to setup the current postdata. Normally a standard loop does this by calling the_post
on the query, but you’ve chosen to use get_posts
instead.
This is what a standard post WP_Query
post loop should look like:
$query = new WP_Query([ ... ]);
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
//.... display post here
}
wp_reset_postdata();
}
Related Posts:
- Stuck in Order by more then one
- Displaying custom field according to date
- Sort a custom post with ACF: Date Picker & Display Featured!
- Group by custom field value (start and end times)
- meta query not retrieving posts
- How to I add count of custom posts listed in a post as a prefix to its title
- WordPress duplicating posts from single loop
- Advanced custom field boolean value in custom post type
- Why is my WP Query not returning first result’s post meta?
- Reworking function for counting custom post type posts count
- Get only used meta_values
- Number of posts in the archive
- Custom query for custom post_type
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Querying & displaying custom post type into an existent page [closed]
- How to get a custom type post data when it has a connection with another custom type post?
- Custom post type showing same Post on all Pages
- Why would social icon badges disappear after adding a custom post type?
- ACF repeater field usage
- List of users that clicked a ‘Join’ button at single post
- Post loop count is not in order
- populate array with posts
- How to Make infinite loop of post
- get_posts seems to be skipping the last Post
- Displaying multiple post types on home page
- Can anyone clarify difference between archive-{posttype}.php, type-{posttype} and date.php?
- Conflict between wp_list_pages and get_posts – list pages not displaying
- How to inherit field value from parent post into in child / sub post
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- Custom Post Type page sorts differently on different environments
- Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?
- set_query_params using custom params defined in functions file?
- Custome fields not displayed
- Return number of all custom posts type by author in all statuses
- Create short URL with auto 301 redirect
- ACF for custom post type archive pages: which hook to use?
- How to define the template for custom posts?
- Batch Extract Date from post title and put into ACF custom field
- Is it possible to use array_walk() to append terms to an array of posts?
- custom hierarchical taxonomy and custom post type list contains surplus posts
- Query entries from custom post type in an ACF flexible content field
- Why is wp api returning old acf values?
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Distribute Custom Post in different pages
- get custom post type value in header.php [closed]
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Advanced custom fields Post Object image field not displaying in custom post type single.php
- Sum and count of custom field values
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to export custom post type with ACF to individual file with automation?
- Custom fields not showing in custom post type
- Custom post types, disable fields
- Custom Post Type with Configurable Sidebar via ACF
- How to get custom post type title, excerpt, thumbnail and permalink by post ID?
- Incorrect ordering of custom post type based on time
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Get posts by category name
- Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
- Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis
- ACF Relationship Posts how to show additional content
- wp-includes does not contain a feed template
- Using WP meta query to show custom post types by a start and finish date
- Limit search field to just search a custom post type with custom fields
- How to properly use Categories with Custom Post Types
- Redirect to URL if x number of days passed
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Advanced custom field – posted fields from custom post type
- 4 posts per page from single category
- Excerpt length: get first paragraph
- Query custom posts of logged in user only
- SQL query – get ids – Advanced Custom Fields / WPeC
- Custom field with Types: get custom field’s value label (of type select)
- Display a random customposttype2 excerpt in single-custompostype1.php that shares same taxonomy
- Getting the list of the latests posts and custom type posts in the homepage
- How to query custom post types with multiple keys?
- How to display author details in a custom post type in the wordpress backend?
- Show posts associated with ACF post object and custom post type
- Show/hide posts and categories based on user meta
- Fetch data from two custom post types and create multidimensional array for output to html table
- date_query empty results with custom post type
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- How can i show ACF in post excerpts
- ACF – Retrieve custom taxonomy from a relationship field
- How to set a ‘page’ as parent of a custom post type?
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- Custom front-end form for adding post – Category problem
- Set up a WP Cron scheduled event to update calculated ACF field
- Query filter by value in meta_value array
- Show Post Revisions on front-end
- count & sum the value of custom field of the author post in dynamic posts
- How to show Custom Post Type – Case Study using Shortcode & ACF
- Add custom post related by custom field to custom post
- get_posts() returns empty on custom post type /wp-admin/edit.php
- Create if else for post types in WP_Query ‘post__in’ values
- Create loop from selected terms in ACF taxonomy field
- Sort custom posts by date and then by taxonomy
- Grouping custom wordpress post types by acf value
- Get_post_custom not fetching value from array wordpress