Display the video of a post_format Video

I made a function that return the iframe for the first video inside the post with id $post_id: function get_first_video_embed($post_id) { $content = apply_filters(‘the_content’, get_post_field(‘post_content’, $post_id)); $iframes = get_media_embedded_in_content( $content, ‘iframe’ ); return $video_post_iframe = $iframes[0]; }

How to modify get_the_excerpt() when post-format equals ‘quote’?

While writing the question in SE I already found the solution: add_filter( ‘get_the_excerpt’, ‘get_custom_the_excerpt’ ); function get_custom_the_excerpt($excerpt) { $post = get_post(); $format = get_post_format( $post ); // modify excerpt if it is a quote, for example set title as author if ($format == ‘quote’) { $output=”<q>”. $excerpt. ‘</q> <p class=”quoted”>’.get_the_title().'</p>’; } // return excerpt without … Read more

About post format

Post formats are not magic. Your theme needs to actually have a code to generate different HTML (or apply different CSS rules) for different format. Having the theme “suuport” post formats is nice for future compatibility of the content, but by itself it doesn’t do anything to how the content is displayed.

Audio post format with Advanced Custom Fields

Advanced Custom Field plugin uses get_field() to retrieve values. Your code should be something like: $audio = get_field(‘audio_post_format_url’, $post->ID); var_dump( $audio ); # To make sure you’re retrieving the right value echo wp_oembed_get( $audio ); Note that get_field() does not need a second parameter, it will take the current post ID if omitted. If var_dump( … Read more

Post format or Type for List Type Posts

You may simply use register_post_type and register_taxonomy to do so: function add_cpt_salads(){ $labels = array( ‘name’ => __( ‘Salads’, ‘your-text-domain’ ), ‘singular_name’ => __( ‘Salad’, ‘your-text-domain’ ), ‘menu_name’ => __( ‘Salads’, ‘your-text-domain’ ), ‘all_items’ => __( ‘All Salads’, ‘your-text-domain’ ), ‘add_new’ => _x( ‘Add new’, ‘Salads’, ‘your-text-domain’ ), ‘add_new_item’ => __( ‘Add New Salad’, ‘your-text-domain’ … Read more

How to add meta box for current post format?

If you want it just for the native post post type, then put this in your functions.php add_action(‘init’, ‘my_theme_setup’); function my_theme_setup(){ add_theme_support( ‘post-formats’, array( ‘aside’, ‘gallery’ ) ); } The Post Format meta box will now appear down the side of your screen on the post creating/editing page. Full list of available post formats to … Read more

get_template_part() Not Working in Loop

Thinking about my comment…wouldn’t it be simplier to say: <section id=”content” class=”site-content blog-page”> <div class=”container”> <?php if ( is_home() || ( is_front_page() && is_home() ) ) : ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h2> There are posts but template parts aren’t found </h2> <?php get_template_part( ‘template-parts/post/content’, get_post_format() ); ?> <?php get_template_part( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)