I’d suggest doing it this way to avoid running into problems where you split within a sentence/paragraph.
Try splitting on <p>
– then put the first element (first paragraph) into <div class="content-first-half">
and the rest (if any) into <div class="content-second-half">
in your template.
It should be something like this (assuming $content
has the html for the post)
$paragraphs = preg_split('/<p/i', $content);
array_shift($paragraphs); // ( remove first empty element
$first_half="<p" . array_shift($paragraphs);
$second_half="<p" . implode('<p', $paragraphs);
I chose <p
to split on since presumably the content will be formatted into paragraphis with <p>
tags – but could have inline styles/classes attached, so you can’t split on a <p>
.
As far as getting the post’s custom field, this should be a good start.
Related Posts:
- How can I add dropdown widget/box to admin post page?
- Custom post type loops with different page templates
- Limit Authors to their Own Posts on front-end excluding admins
- redirect after submiting post for review
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Featured image in custom post is being disabled
- Why isn’t my custom post type using the corresponding custom post template?
- Display a query with multiple post types and same relationship on a single page
- Set posts of a custom post type to be private by default?
- previous_post_link() and next_post_link() with a custom post type?
- Setting a custom sub-path for blog without using pages?
- Custom post status not working
- Date archives for custom post type
- Clean URL permalink for custom post type
- Multiple Content Block
- Append taxonomy terms as class names in markup?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- How do you output custom code between posts in the loop?
- Use template for posts with a particular category grandparent
- is_page_template not working as expected
- I am having a problem with form updating/editing WordPress post on the frontend
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- Output custom post shortcode. Help spot the error.
- WP_Query is printing out only one post when posts_per_page is set to multiple
- GravityForm: Populate Dropdown with custom post type [closed]
- Trying to edit the single page from a Custom Post
- Loading all files within a directory
- Blog page showing same content as homepage
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Notice: Undefined index: suppress_filters
- Using wordpress template tags within an array
- What’s the difference between same wp functions get_posts(); functions in different form?
- If post has custom field then display css-class
- How to customize a permalink (URL) structure?
- Can I list a custom post type within another custom post type in the admin area?
- I would like to have different styles for my posts based on the content of each post
- Set URL link to featured image of custom post type
- AJAX load more for different custom post type loops
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- Show current user posts in custom post type query
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- Get post format
- How to add new post using a form to categories when categories are using as menu
- How to set the mainpage of a custom post type?
- Different post title, keywords and description
- post_content is stripping HTML when adding a new post? [closed]
- Using Wp_Query, Json to add Highcharts series data
- Send post changes to set email addresses (not users or subscribers)
- Let users upload image(s) to the post from front end
- Foreach loop returning more than one item when querying taxonomy
- Function to erase every post from a taxonomy
- Display author box on just certain category posts?
- Post type Echo code is repeating on homepage
- Function to allow single post template based on custom taxonomy?
- Conflict in function to allow single post template based on category
- Is it possible to get the specific content on the search page?
- set object terms after some some time of published post – functions.php
- php dynamic content inside shortcode
- Why is my custom post content only viewable when signed into WordPress?
- How to change Elementor Template for Single Page Post on Load
- update custom taxonomy custom fields
- Title and URL Error in Breadcrumb Navigation for Custom Post Types
- Check that a slug is present in the get_terms request
- open custom post type in popup window instead of page
- Post template with breadcrumb needs to show page navigated from
- Pagination not working in custom post type. Help
- How to add specific terms in a custom post type?
- Assigning categories to custom post types via a front-end form; only works for native post type
- WordPress – display relationship between blog posts and custom posts
- Post template not applying on theme (potentially rendering as Page template)
- Limit custom post type to the authors only on front-end!
- Load info from customposttype into template page
- wp_post_delete is deleting all offices
- Accessing download link from the loop with WP Download Manager Pro
- Create posts inside CPT post
- Persist meta box choices throughout all posts of same post type
- ACF field check value of field on all other articles
- News post with multiple permalinks? When opened from different page
- Change Search display for Custom Post Type
- subtracting the current post form then whole loop, which is generating all CPT titles
- How to assign post to category
- Assign for all post of a post type a specific single-post template
- Custom Post By Category
- Stored meta from attachment, video length?
- How to get the posts that my following users are liked?
- Duplicate posts in my custom loop
- When post is Published, insert into custom table a number – custom post type
- Post that populates itself (almost) automatically using data from imported excel file
- How to mark posts as visited
- Work and Display a Custom Post Type as a normal Post
- Custom post type with two templates
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- can’t see categories in appearance-menu-categories
- Function not pulling image or text from custom post type
- Search page for custom post type
- Custom Loop for custom post type. Compare by meta_value?
- Code in custom widget queries all posts, when it should only query the current post