Excerpt length: get first paragraph

Assuming your paragraphs are marked with <p> tags, which can be set in the ACF field options, the following should work: function custom_field_excerpt() { global $post; $text = get_field(‘news’); if ( ” != $text ) { $start = strpos($text, ‘<p>’); // Locate the first paragraph tag $end = strpos($text, ‘</p>’, $start); // Locate the first … Read more

Custom field Search with Relavanssi

I don’t have Relevansii installed but it looks like you can hook to relevanssi_search_ok and return false, and Relevansii will pass back the unmodified search. add_filter(‘relevanssi_search_ok’, ‘__return_false’); I am going to assume that Relevansii is using the ordinary search form provided by the theme, meaning that you could modify, or create, searchform.php to include the … Read more

Perform function on publish AND save (not just save)

Instead of taking meta values from get_post_meta function take it from $postarr array because when initial publishing of the post there isn’t any values for event_datestart and venue_name in database and it returns empty string. Updated Code : function set_event_title( $data , $postarr ) { if($data[‘post_type’] == ‘event’) { $getdate = $postarr[‘event_datestart’]; // Replace event_datestart … Read more

Show related posts on single.php, grouped by taxonomy terms, with Advanced Custom Field post object selected

I’d recommend creating 3 separate [‘associated_items’] fields instead of 1. For Example: [‘associated_articles’] & “Filter for taxonomy term: Articles” [‘associated_presentations’] & “Filter for taxonomy term: Presentations” [‘associated_news’] & “Filter for taxonomy term: News” Note: Filtering for the taxonomy term, limits the related posts available to choose from as well, which results in a better user … Read more