Get post first paragraph without html tag [duplicate]

You can create function using wp_trim_excerpt to grab the first paragraph of text and ignore images function custom_excerpt($text, $raw_excerpt) { if( ! $raw_excerpt ) { $content = apply_filters( ‘the_content’, get_the_content() ); $text = substr( $content, 0, strpos( $content, ‘</p>’ ) + 4 ); } // strip any images on the code $text = preg_replace(“/<img[^>]+\>/i”, “”, … Read more

Get posts under custom taxonomy and custom post type

You will need to use this code: $the_query = new WP_Query( array( ‘post_type’ => ‘courses’, ‘tax_query’ => array( array ( ‘taxonomy’ => ‘courses_category’, ‘field’ => ‘slug’, ‘terms’ => ‘yourterm’ ) ), ) ); while ( $the_query->have_posts() ) : $the_query->the_post(); // Show Posts … endwhile; You can convert this in shortcode and just append it on … Read more

Show content from multiple pages (not posts) on home page

You can use the below query to get content from specific pages by id or page slug // WP_Query arguments $args = array( ‘page_id’ => ‘12,14,78,89’,//replace the page ids //’pagename’ => ‘aboutus, contact’, //or use page slugs ‘post_type’ => array( ‘page’ ), ‘post_status’ => array( ‘publish’ ), ‘posts_per_page’ => ’10’, ); // The Query $query … Read more

Custom field in PHP file

Assuming your $hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true ); is giving you the correct value you need, you are storing your that in the $hasp_expire_date variable. So edit that second line to: $num_comments = get_comments_number( $block_data[‘id’] ); // Pull in the value you need $hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true ); // You are going … Read more

Can you add a shortcode to a custom post type that gets the post_title, post_content, etc. and then passes that to a plugin function?

1.) First, when creating a shortcode, you must return data, not print. 2.) Yes, you must explicitly specify the post id, print the id in the button or form of your shortcode, you can also use the shortcode attributes to generate a button for a specific post (See example) Your shortcode code should be like … Read more