Yes! You meant to use get_the_title()
which returns the title as a string. the_title
instead outputs it to the browser. The same is true of many other functions in WordPress, e.g. the_post_thumbnail
vs get_the_post_thumbnail
or bloginfo
vs get_bloginfo
For future reference, a search on https://developer.wordpress.org will usually reveal related functions
Related Posts:
- posts order by title second word
- How to output the title of the blogs home page
- Shortcode Not Working in Slider When Added To Post Title
- How to search posts by title with special characters in WP_Query?
- Query posts only with featured image
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- ‘Trying to get property of non-object’ when using WP_Query with ‘fields’ => ‘ids’
- Order by Category and Post in WP custom Query
- get custom post type by tag
- Execute a large WP_Query with many “AND” Meta_Queries?
- Using WP_Query To Get Posts Randomly From today
- Get All IDs Of A Post Type Using WP_Query
- How to know which one is the main query?
- Multiple endpoints in one URL
- WP_Query can’t exclude more than 1 author?
- How to order posts by custom WP role?
- Get term by custom term meta and taxonomy
- Generate a tabbed submenu — from taxonomy term or submenu item — with sample content
- posts2posts query using connected_items array issue [closed]
- Explanation of WP_Query
- Paginated HTML Sitemap
- Meta query field order together with post_date order causes posts without the meta field to be unordered
- Undefined property: WP_Query::$post
- Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?
- How to get posts on a specific date – WP Query
- WP_Query no posts with tax_query
- WP_Query meta_query >= date
- Query different number of posts with different formats in one go
- Extending woocommerce admin product search
- Pagination is broken and I need help fixing it
- need to exclude APP_TAX_STORE => $term->slug
- paging in WP_Query on static page
- Query by multiple meta elements not seeming to work – wordpress is timing out
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Fetch posts that match term slug first two letters (wp query)
- How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?
- Query with search and subscribers only output
- Post loop for all taxonomy terms
- Taxonomy order exception for specific term
- next_post_link / previous_post_link not working with WP_Query
- Customy WP Query Args are convertet in SQL result
- Include post content of linked posts in search
- Query_posts works when appending via AJAX call wp_query doesn’t?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- wp_trim_words strips dashicons
- Save (and exclude) posts from loop to use in another loop on page
- Get all posts with empty meta_value
- Count identical post titles
- get_page meta query not working, maybe a bug?
- WP_Query->request has a limit
- Add parameter to first post only
- relation OR instead of AND – Filtered term ID’s in loop
- How to get specific string in explode array?
- using nav menu id’s
- Ignore image urls in wp_query search
- filter posts by meta key with pagination
- Single post – display list of all posts + specific post
- Modify output of custom loop using WP_query
- What’s wrong with this wpdb query?
- The Events Calendar, wp_query returning event date not published date
- meta_query where the meta value is not the post title
- SQL query injection with fifu image
- How do I use multiple similar queries with WP_Query on the same page?
- WP_Query order by multiple meta keys & fields
- WPQuery Date and ACF
- Is WP Query skipping to check next post when an argument is not met?
- Save large WP_Query to transient === false
- 3 posts from each existing category on one page
- meta_query is overriding default search
- Custom Woocommerce Product Query
- How can I write a WP_Query that is this specific?
- How to show specify category template for both parent and child category
- How to query most recent post for each author?
- Custom Query Pagination not working on static front page
- Post Template Query with WP_Query?
- WordPress search page pagination displaying but not functional
- query all posts published by certain user id
- How to create URL parameters to run custom queries?
- Query custom meta value – post view and date meta
- Query Top Set Custom Taxonomy In Given Timeperiod
- Custom taxonomy and query multi conditions
- Orderby Date and Category
- WP_query issue with no posts
- How to get query results for the next page
- Pagination for custom query throws 404 errors on last pages [duplicate]
- Order posts by custom column using pre_get_posts
- wp_query in form method of widget breaks customizer
- Featured image not showing on page
- Add filter to Orderby Parameter using Array
- Iterate through ID’s in loop
- Need help setting up a search form for wordpress [duplicate]
- problem in query_vars parameters
- Limit Tags display and ad Drop Down Menu
- Multiple loop for “featured” items returns wrong posts
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- Add banner after the third post [closed]
- Display Featured image from custom post type category (custom taxonomy) wise
- new WP_Query with order args – no more distinction between categories
- How to make OR condition in WP_Query