Why doesn't this work?! <?php echo get_post_format_link('standard');?>
:( Any hints? All the other formats work.
Put this in your function.php
function akv3_query_format_standard($query) { if (isset($query->query_vars['post_format']) && $query->query_vars['post_format'] == 'post-format-standard') { if (($post_formats = get_theme_support('post-formats')) && is_array($post_formats[0]) && count($post_formats[0])) { $terms = array(); foreach ($post_formats[0] as $format) { $terms[] = 'post-format-'.$format; } $query->is_tax = null; unset($query->query_vars['post_format']); unset($query->query_vars['taxonomy']); unset($query->query_vars['term']); unset($query->query['post_format']); $query->set('tax_query', array( 'relation' => 'AND', array( 'taxonomy' => 'post_format', 'terms' => $terms, 'field' => 'slug', 'operator' => 'NOT IN' ) )); } } } add_action('pre_get_posts', 'akv3_query_format_standard');More information here.
<?php
$args = array(
'showposts' => 9,
'tax_query' => array(
array( 'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array('post-format-video','post-format-quote'),
'operator' => 'NOT IN'
)
)
);
query_posts( $args );
while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; wp_reset_query(); ?>
from
http://www.tristarwebdesign.co.uk/blog/wordpress/query-by-post-format-in-wordpress/
When you assign a non-Standard post format to a post, a record gets added to the wp_term_relationships table. This record contains your post number and the term_taxonomy_id, which joins via wp_term_relationships to the post format in wp_terms. When you assign a Standard post format to a post, no record for post format is added to wp_term_relationships. If it was previously assigned another post format and changed to Standard, the record is removed from wp_term_relationships. Unfortunately, get_post_format_link relies on having that record in wp_term_relationships, so won't work with Standard post format.
For example, when I changed a post's post format to image, a record was added to wp_term_relationships, which eventually pointed to wp_terms >> post-format-image. When I changed the post's post format to Standard, this record disappeared. In WP's codebase, get_post_format_link uses get_term_by('slug', 'post-format-' . $format, 'post_format' ), and with the missing related post format record for Standard, we all lose. :-D
This might answer your original question of why it doesn't work. I wish that I could offer a slick solution, especially given your immensely helpful WordPress posts!
post-format-*
taxonomy is not set, and the callget_term_link()
used in this function will fail.