I was looking into this because all of the text was not showing on my slider, and the slider had a height set with overflow: hidden
. I didn’t think there was a simpler solution than to create a filter for the_content
until I stumbled across this one…
It’s a css solution 🙂 All I am doing is using nth-child
to display the first five items, then hide the rest:
#main p:nth-child(1n+6) {
display: none;
}
This is a great solution, because I can use media queries to change the amount I show based on screen size, that way I don’t have to have one magic number and it’ll look good on large or small screens.
Hopefully this helps someone else trying to do the same thing.
Thanks,
Josh
Related Posts:
- ‘the_content’ filter removing html tags from post content
- How to add defer=”defer” tag in plugin javascripts?
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- the_content and is_main_query
- How to add a custom CSS class to core blocks in Gutenberg editor?
- How to appending to the_content using add_filter with custom post type?
- Why is javascript allowed in my post content?
- How to wrap an element around an iframe or embed in content automatically?
- WordPress Internal @ Mentions
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Where to hook into post content?
- Insert Custom HTML After Shortcode
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- Add whitespace between Chinese and other letters
- Hook added to the_content seems to be called multiple times
- Get excerpt from $post->post_content
- Add Class to Specific Paragraph of the_content()
- add_filter for specific pages
- AJAX filter posts on click based on category
- Remove left alignment option in core/image block
- What params are available with the_content filter?
- Using variable from one filter in another filter
- apply_filters(‘the_content’, $content) alternative
- What effect does the_content filter have on performance?
- How can I display image metadata?
- Add post/page ID to inserted links within the_content
- How to apply content filter permanently?
- How to prepend text to the_content, but after img/shortcode
- Format content value from DB outside of WordPress filters
- What is the filter hook for custom fields content?
- What functions are included in apply_filter(‘the_content’)
- Filter Gutenberg Blocks Content
- Return array of images after content
- Nested calls the the_content filter
- Remove tags from the kses filter
- How can I filter block registration based on post-type? (Block alignment settings)
- Editing
- the_content filter – checking the post
- Apply the_content filter, but prevent other hooked actions
- Wrap h1-h6 in a div
- How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
- Function the_content not working
- apply_filters/do_action tag characters limit
- Add attribute to script loaded by the theme
- When to use add_action when registering/enqueuing scripts
- add_filter(‘the_content’, ‘…’) stops pagination from working
- Remove CSS & JS files from WordPress Main Page For Increase Pagespeed?
- Post Content, Special Characters and Filters
- html tags in gettext hook get escaped
- Filter on the_content doesn’t update the content being searched via register_rest_route
- How to hide Ads in between posts on AMP? [closed]
- Add content as soon starts
- Remove Content Filter
- tag removed not using a filter
- Replace audio links with jplayer using the_content filter
- Add a div of content within the_content after a certain block
- How do you get specific tags from the_content?
- Can i use multiple ‘the_content’ filters?
- get_post() containing gallery is outputting an unmatched closing div at the end of the content
- Load Posts’ individual body content on index starting at char 200 of each post
- Excerpt is being added above the content, but it should be after it
- What is the earliest hook to modify post content?
- Filter content for get_the_content()
- Shortcodes within the sidebar text/html widget: How to preserve the raw HTML output of the shortcode?
- Why is overwriting $GLOBALS killing the_content()?
- add_filter the_content doesn’t work
- Adding html banner to posts
- How can I get the default content of WordPress post?
- Email Obfuscation: Is antispambot() Acceptable? [closed]
- alternative to the_content filter
- add_filter to the_content after apply_filters
- How do I add tags to entire comments, not just their text
- How to stop DOMDocument destroying embeds?
- Scanning for custom embed and prefetching
- the_content getting current page content instead specified ID
- get_post() with filters applied
- “The editor has encountered an unexpected error” After add defer tag to java script
- How to bridge the gap between dynamic back-end data and front-end output?
- how to output HTML tags in post_content and not as plain text
- How to wrap pattern-matches from the_content in [wiki]-shortcode tags
- Set Microsoft Word links to open in new window/tab
- How do I isolate the reason a wordpress filter is not running?
- the_content filter not working when Jetpack activated. Any idea?
- Apply a filter str_replace on specific caracters array in the_content()
- How to get to the date of the uploaded file
- changing size image within the content
- Can’t get content of all (19) posts – Incomplete Chunked Encoding
- Add class to all parent elements inside the_content
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- filter on the_content stopped working when I updated to WP 3.6.1
- post->post_content filter
- Replace image scr with it’s surrounding href
- After adding filter to plugin’s code, post’s content doesn’t display
- This code works, but breaks the media uploader. How do I integrate it in a way that won’t?
- How do I check whether a checkbox is checked in jQuery?
- Filter the blog’s title without using global variables
- Add guid filter to attachment in media library grid mode
- Filter on the day of the week from timestamp
- Is this correct usage of filters in WordPress [closed]
- Passing variable from filter