Add read more to the_content

You could add a link manually like: <a href=”https://wordpress.stackexchange.com/questions/88976/<?php echo get_permalink($post->ID) ?>”>Read More…</a> If you want to add the link at the end of the content you could do: return implode(‘ ‘, array_slice($words, 0, $word_limit)) . ‘<a href=”‘.get_permalink($post->ID).'”>Read More…</a>’;

get_post_fields as an excerpt

Give this a try. Basically, your get_posts looks OK, but you need to setup the post information. This leats you use the normal functions the_something and get_something without having to pass in a post object / ID each time. Just remember to call wp_reset_postdata(); anytime you use setup_postdata(). <?php $random_post = get_posts(array( ‘category’ => ‘objects’, … Read more

Cannot Find Hook that is changing the_content()

It’s unusual for the_content to be rewriting image classes like this; it sounds like it could be a plugin (or theme function) which is doing this. Have you disabled all plugins just to check? Having said that, most of the functions in core that hook into the_content are located in wp-includes/default-filters.php (apart from the oembed … Read more

Remove a div with ID from the_content WordPress

with the_content filter hook you can modify the content using PHP preg_replace search and replace function remove_specific_wrapper($content) { $content = preg_replace(‘#<div[^>]*id=”some_id”[^>]*>.*?</div>#is’, ”, $content); return $content; } add_filter(‘the_content’, ‘remove_specific_wrapper’);

tech