Custom query Custom-Post-Types creates error

just use query_posts(‘post_type=team-member&posts_per_page=2&paged=$paged’); instead of $wp_query = new WP_Query( array( ‘post_type’ => ‘team-member’, ‘posts_per_page’ => 2, ‘paged’=>$paged ) ); and then the while loop as if(have_posts()) while(have_posts()) : the_post(); instead of <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

create a link to a random post within the current category

I think it’s better to use get_posts function. You can change the number of posts that you want. I set the category id if you’re in a category page. <?php rewind_posts() ; $args = array( ‘numberposts’ => 1, ‘orderby’ => ‘rand’) ; $exclude_posts = array() ; if ( have_posts() ) { while ( have_posts() ) … Read more

How to add a Variable to post query

I’m not sure if is this that you need, but try to “explode” it… <?php // Headlines variable can control admin area // Does this return the string “2,3,4,5” ??? $headlines = get_option(‘t_turmanset’); query_posts( array( ‘numberposts’ => 4, ‘post__in’ => explode(“,”, $headlines) ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); … Read more

Can I include get_posts in this array?

I’m assuming there is an option in the array that is meant to receive an array of options for the checkboxes…? In which case, you can use get_posts to obtain an array of post objects (of which ever type), and then loop through this, to create an array of post titles: For example.. $args=array(‘numberposts’=>-1,’post_type’ => … Read more

Trying to use WP_Query to return post with and without meta values

You use both ‘meta_key‘ and ‘meta_query‘ – it is a wrong usage. Remove this code: ‘meta_key’ => ‘date’, and try again. After remove $cat WP produce sql query: SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) WHERE 1=1 AND wp_posts.post_type=”post” AND (wp_posts.post_status=”publish”) … Read more

List WordPress Post and Related Attachments outside of a post page

First of all don’t use query_posts function, use the WP_Query class instead. Secondary you forget to fetch attachments for a post. You can get attachments list by calling get_children function. $args = array ( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘audio’, ‘numberposts’ => -1, ); $the_query = new WP_Query( ‘portfolio-tags=apple&post_type=portfolio&posts_per_page=-1&orderby=title&order=asc’ ); if ( $the_query->have_posts() ) : … Read more

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