list pages by custom_field?

Not sure if this help. If you use normal wordpress loop to query post or pages then you can do this by using query_posts You need to place a line of query_posts before the loop start and it might look something like this ( you might need to add some more parameter for getting only … Read more

How to reduce three query to one in multiple output template?

query for all posts at once and set a counter variable to check where you are in the loop. $products = get_posts( array( ‘numberposts’ => 7, ‘post_type’ => array(‘product’) ) ); $count = 1; foreach( $products as $product ): if( $count == 1 ): // first post elseif( $count > 1 && $count < 5 … Read more

How do I separate author avatars and comments in 3.4.2?

Ok, so this is what I’ve done. If anybody has a better idea I will leave the answer open for a few hours and choose it! <?php if($comments) : ?> <ol> <?php foreach($comments as $comment) : ?> <li id=”comment-<?php comment_ID(); ?>”> <?php if ($comment->comment_approved == ‘0’) : ?> <p>Your comment is awaiting approval</p> <?php endif; … Read more

Removing custom post type name in single article URLs

Use the post_type_link hook, like this for use hash in link faq is the example custom post type add_action( ‘post_type_link’, ‘wpse70763_post_type_link’, 10, 2 ); function wpse70763_post_type_link( $link, $post ) { $post_type=”faq”; if ( $post->post_type === $post_type ) $link = get_post_type_archive_link( $post_type ) . ‘#’ . $post->post_name; return $link; } then unset($wp_rewrite->extra_permastructs[‘faq’]) On the init of … Read more