GET the excerpt by ID

Hi @Robin I. Knight: I view get_the_excerpt() as a function with legacy design. As WordPress usage has grown there are many newer use-cases where it doesn’t fit but where the newer functions for getting different data do. One example is the now frequent use of an $args array of function options. But it’s easy to … Read more

Turn a URL into an Attachment / Post ID

Massively improved function developed for plugin heavy on images: if ( ! function_exists( ‘get_attachment_id’ ) ) { /** * Get the Attachment ID for a given image URL. * * @link http://wordpress.stackexchange.com/a/7094 * * @param string $url * * @return boolean|integer */ function get_attachment_id( $url ) { $dir = wp_upload_dir(); // baseurl never has a … Read more

When is the ‘post_content_filtered’ column in database cleared by WordPress?

Every post update in WordPress is handled by the wp_update_post function. This function has some defaults, and for post_content_filtered the default value is ” (empty string). Once the defaults are merged with args passed to function via wp_parse_args it means that every time a post is updated and post_content_filtered is not explicitly passed, it is … Read more

Get Posts Under Custom Taxonomy

Your tax query is incorrect, field should be the field you want to query on: term_id, name, or slug – $posts_array = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘fabric_building’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘fabric_building_types’, ‘field’ => ‘term_id’, ‘terms’ => $cat->term_id, ) ) ) );

What does this PHP function code mean? [closed]

Basically, this is a programming pattern for namespacing code within a WordPress plugin. Typically, you can only have one function called init() in a program, but more than one author will try to use that name. Placing function names in a class is a way around this limitation. For example: class Towfiq_Person { static function … Read more

Get WordPress post content by post id

Simple as it gets $my_postid = 12;//This is page id or post id $content_post = get_post($my_postid); $content = $content_post->post_content; $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content;