How to limit wordpress the_excerpt() dynamically

according to the documentation, it is more correct to change the length of the excerpt using add_filter: add_filter( ‘excerpt_length’, function(){ return 10; }); you can make your own function based on this, like this: add_filter( ‘excerpt_length’, ‘new_excerpt’, 10, 1); function new_excerpt( $lenth ){ return $length; }); … apply_filters( ‘excerpt_length’, 150 );

How to hide protected posts from archive?

There are 2 answers depending on where you want to do this. One has good news, the other has bad news Anywhere That Uses Post Queries Modifying the SQL is rarely necessary here and usually a sign that something was overlooked. In this case, WP_Query already provides a simple parameter to do this named has_password. … Read more

WordPress – display relationship between blog posts and custom posts

Below is the updated code to fetch posts, please check is that helpful: $documents = get_posts(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘our_people_author’, // name of custom field ‘value’ => ‘”‘ . get_the_ID() . ‘”‘, // matches exaclty “123”, not just 123. This prevents a match for “1234” ‘compare’ … Read more