You can use “wp_trim_words” function for this case.
Exam: To display the first two words.
echo esc_html(wp_trim_words( get_the_title(), 2, ” ) );
Use this code within your H1 tag.
You can control the number of words you want to show in the title by changing the second parameter of the function “wp_trim_words” to know more about this function visit wordpress.org
Related Posts:
- is_admin returning false in backend in server side rendered block
- Display posts by month
- Custom SQL query to get List of posts with featured image url
- get_the_content if it contains multiple lines it results in SyntaxError
- Looking to exclude blog posts from category Previous/Next buttons
- Automatic Excerpt Not Working
- Using a javascript file to access a get posts array
- WP Insert Post function – Insert Post Thumbnail
- How is WordPress manipulating the posts like there are folders?
- Get taxonomy terms only of the WP_Query current posts
- How to get 2 or multiple custom post types in wordpress functions.php
- Trying to make php run in a post
- Remove posts after a given amount of time
- Hide wordpress field if data is empty in post!
- How to show part of the_content?
- How to set a min number of words for a blog post
- How to programmatically add Gallery Block to Existing Post Content
- Get post id in a function when edit/add a post
- Gutenberg block – Save PHP function’s output as HTML?
- Which hook/action will help me solve my problem?
- Open post-content in archive page in a Modal box with bootstrap
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- Get children post mime type using parent post_ID wp_post
- Add class to group inner container
- Pagination on Custom Post
- $wpdb returns duplicate posts
- How to avoid duplicates when creating recent network posts
- Update post title from external file?
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- set post limit at load more ajax wordpress
- Multiple requests external data api dynamic block gutenberg
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Array to string conversion on array_map
- Store metakey value as an array
- How to use mysql LIKE with wpdb?
- Do I need to edit my theme in order to change the title of my blog page?
- Add new post in existing categories using wp_insert_post
- How do I add more options to the post-new.php page?
- Incrementing PHP variable onclick to display posts by month
- Get the id of all images in a post
- Do not duplicate posts with multiple categories in multiple loops
- Four posts per row [closed]
- Need help removing […] after excerpt
- WordPress Search
- Update value of a associative array with update_post_meta
- Wrap posts p tags in div
- Want to unrestrict plugin block
- Pagination in single.php
- Additional file upload in Gutenberg page options/featured image
- Edit and delete permissions pages and posts
- Generating 10 000 WordPress posts using PHP and avoiding Server Timeout error
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- Post form – AJAX won’t upload featured image – Plugin development
- How to get post image caption by index
- posts_per_page displays only 2 posts instead of 4 posts
- Is there anyway I can call the year once?
- Check $post->ID against multiple values
- register_block_type is not working properly
- Posts missing on author page
- How to allow users to save list of posts in wordpress?
- Infinite looping next post link within a certain category on a post
- Categories does not show Block editor WordPress
- WordPress recent post
- Block that renders html saved in a php file
- Need to show 7 posts from actual date
- Show Gutenberg facebook embed with a custom theme
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- How to center all text body in single.php at once?
- My blog posts section seems to be rendering the other blog posts inside the first? :/
- LinkedIn Share Post Button
- Get the total Author Favorited posts
- Get current_post in reverse order with pagination
- How do I generate formatted permalinks as specified in backend options?
- Using Tag Groups: Displaying groups and adjacent tags of current post
- Setting at job with shortcode not working
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Basic PHP question (displaying post title over thumbnail) [closed]
- Only Get A Certain Number of Posts From WP_Query
- Post from front end form to post_meta
- media_handle_sideload() returned post_id being incremented
- How to call post title and post summary to other part of site?
- Saving Post redirects to 404 page when php $_GET variable in post body
- Insert wordpress tags below posts via functions.php
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- Add Custom Post Type on the Fly or create an array
- link to page_for_posts
- How to customize posts in WordPress by using HTML and CSS?
- foreach all the post
- How to create a loop that will display one post and stop?
- $post->ID calls for current page, but what is the code to call for any new page created and published in WordPress?
- Blog Posts not sorted and pagination not adjusted after filtering some category
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- Bulk data save in custom table
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- How to change post date and post time in WordPress automatically with a function
- Global update of records after import WP All Import Pro
- Adding features to Gutenberg without theme.json
- How to edit templates created in the block editor in code / template files not updating
- Embed dynamic media query in a Gutenberg block