Get and Trim Full Post Content in WP Query
I think the best thing to do would be to just simplify what you’re doing. I’d just do something simple with it if all you’re attempting to do is trim the amount of characters output. I’d use mb_strimwidth
to trim the characters, and within that run wp_strip_all_tags()
on get_the_content()
. Like this:
$content = mb_strimwidth(wp_strip_all_tags(get_the_content()), 0, 100, '...');
echo $content;
Edit: Forgot to note that if you’re going to have shortcodes in your content, which I highly recommend against, you may also have to wrap get_the_content()
with strip_shortcodes()
.
Related Posts:
- WP_Query() order by post content lenght?
- custom page with post content using read more
- Inline Ajax call after term is appended with a @ or # etc. displayed in div
- WordPress get_posts function, 1300 lines long
- Exclude a category if post is only in that category using wp_Query
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- Tax_query terms ID’s using variable
- Pagination custom query
- WP_Query and name__in
- Query certain amount of posts from multiple dates
- Order posts by tags count?
- Querying Multiple Custom Taxonomy Terms
- Show list of authors with latest post NOT older than a month
- Unable to combine “search value” and “tax_query” using WP_Query
- How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts
- WP_Query search for whole words
- WP_QUERY returns empty set when fired from a WP-CRON scheduled event
- Interupting the loop with extra divs to display data, and how to get it to work responsively
- WP_Query, tax_query and term_meta: How to?
- Custom category search box for WordPress
- How do I reset this wp_list_categories query?
- How to pass many ids in post__in?
- Sub-loop / nested loops Best Practices
- How to echo data after a WP_Query
- Query with a meta value inside a given range
- Pagination of a WP_Query Loop in a child-page page template
- Add condition of user capability in WP_query
- WP_Query returns random number of posts
- How do I run through a WordPress loop called from a filter function?
- How do I get the title of a category in a custom loop?
- Is it a good idea to improve meta query performance by adding tax query?
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- How to display user order by role
- WP_Query | Tax_Query Relation | Unable to use ‘OR’ as it then allows all products, help me finish my query?
- Display filtered results into custom page
- WooCommerce – get product sub categories
- Order by empty custom field
- Warning: Invalid argument supplied for foreach(). when creating a WP_query
- WP_Delete_user link creation
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- New WP_Query loop in admin causes problems
- How to sort a custom wordpress query by combination of meta values?
- How to pass orderby params to $wpdb->prepare()?
- Get author if post has multiple authors
- how update data through ajax and jquery
- What happens to the default query when I use WP_Query?
- Combine results of multiple WP_Query to resemble single WP_Query
- Modifing archive query affects show post count function
- Using WP_Query() in Magento shows error
- For what queries is conditional tags informative?
- Utilising an existing page while using the “s” query parameter
- posts archive page – closing WP_Query loop correctly [closed]
- JSON – Create rest api endpoint for Advanced Custom Fields
- AJAX Breaking Offset Argument In WP Query
- Is it possible (and how to) query single Gutenberg blocks?
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Pagination in html table is not working
- Nested array issue in meta_query
- Query by key or author
- WP_query paged pagination with excluded category still counts it
- meta_query with array as value with multiple arrays
- Why doesn’t my WP Meta Query return any results?
- How to build the WP_Query using the code?
- How go give $value to wp_query
- How to make the ‘request’ filter work?
- Filter for each loop when WP_Query has no posts to show
- How sort products by calculate value? ( custom post meta, price, option)
- wc_get_products() return empty object
- Related categories order posts by category
- How do I use $wp_query->current_post with get_template_part? I’m trying to add post classes (first/last/even/odd) to custom loops
- Why pagination is not working with tax_query param?
- Finding post ID dynamically on click
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Order Element By Custom Field in WordPress
- Display All Top Child Categories / Taxonomy
- how to get custom attachment url?
- ACF Post Object meta-query by title not ID
- Case insensitive ORDERBY in wpquery
- Sorting with meta_query and multiple, optional meta keys
- getting posts by tags
- WP_Query & Duplicate entries
- Query child posts with tax query on parents
- How to break up output of posts for different terms on same page?
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- Calculating efficiently on large amount of data generated by wp_query
- Include post_status check within $wpdb query
- Return on a quest all these meta_value
- Complicated WP_Query
- Why isn’t my Meta_Query running?
- Custom query to show posts
- How to specify a certain amount of images queried, not all?
- Taxonomy related query not working
- How to show featured post first, then separate loop for other posts
- error with $query->have_posts()
- Multiple Orderby is not working right
- How do I subquery with custom meta fields?
- Show number of posts AND number on current page (cannot make it work)
- Advanced Search – Is this possible?