Taxonomy – Exclude post format from showing on page

If you’re trying to hide a post-format on one particular page, then the function below should work. <?php // Exclude post-format from one particular page function exclude_campaigns( $query ) { // is_page() allows for page ID, page title or page slug if( $query->is_main_query() && $query->is_page( INSERT_PAGE_ID_HERE ) ) { $tax_query = array( ‘taxonomy’ => ‘post_format’, … Read more

Get post format and use it as a CSS class in different spans

Every post has a maximum of one format and one status. To echo the format you need: if (get_post_format($post->ID)) echo ‘<span class=”format-‘ . get_post_format($post->ID); . ‘”></span>’; To echo the status you need this: if (get_post_status($post->ID)) echo ‘<span class=”status-‘ . get_post_status($post->ID); . ‘”></span>’; Hopefully this is what you need.

Override post-formats in child theme

It’s import to set the priority for your after_setup_theme higher than your parent theme. The default priority is 10. Using the twentysixteen as example, use priority 11 on child themes’ ‘after_setup_theme’ action. Exemple below: function twentysixteen_child_setup() { add_theme_support( ‘post-formats’, array( ‘video’, ) ); } add_action( ‘after_setup_theme’, ‘twentysixteen_child_setup’, 11 );

Is it possible to customize the post according to post format in single.php?

Yes, it is possible. The easiest and very readable way would be to do this like TwentyX themes do – using get_post_format and get_template_part functions. Let’s say that your current single.php file looks something like this: <?php get_header(); ?> … <?php while ( have_posts() ) : the_post; ?> <article …> … </article> <?php endwhile; ?> … Read more

Query only the posts with a post format of “audio”

Before we continue, I must point out this: $i=1; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query -> query(‘post-format-audio’.’&paged=’.$paged) This is exactly the same as: query_posts( ‘post-format-audio’.’&paged=’.$paged ); Which is terrible. When people advise against using query_posts, it’s not just the function that’s bad, it’s what it does. Thankfully someone told you … Read more

Adding new post format on plugin activation

Unlike the other taxonomies, you cannot use wp_inset_term() to add terms to the post_format taxonomy as you cannot add new terms to this taxonomy. You need to add the terms for the post_format via add_theme_support(), something like add_theme_support( ‘post-formats’, array( ‘aside’, ‘gallery’ ) );

Will renaming a `content.php` file cause any problems?

There shouldnt be any issue, dont forget to change the slug in the template part call: get_template_part( ‘format’, get_post_format() ); the best practice is to have them in their own folder: get_template_part( ‘template-parts/post/format’, get_post_format() ); you can see the folder structure of twentyseventeen just change content respectively. How get_template will work: get_template_part will do a … Read more

If post-format == ‘gallery’ conditional

This one’s an easy fix! The first argument in has_post_format() is a string in the format post-format-{type}, e.g. post-format-aside, or post-format-gallery, etc. So, e.g., change this: has_post_format( ‘aside’ , $post_id ) To this: has_post_format( ‘post-format-aside’ , $post_id ) Wash, rinse, and repeat for all uses of has_post_format(). EDIT Given your example code, I would even … Read more

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