How to put posts in pages using query posts

get_posts may be easier for you to use: $args = array( ‘numberposts’ => 5, ‘category’ => ‘3’ ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <div <?php post_class(); ?> id=”post-<?php the_ID(); ?>” style=”padding-bottom:5px;”> <h2><a href=”https://wordpress.stackexchange.com/questions/22878/<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2> <div class=”post_meta”><?php twentyten_posted_on(); … Read more

query_posts thumbnail condition

the two single quote marks (after the number 1) in this line (of the top posted code section) seem to be causing the error – there should only be one single quote; shown below: query_posts(‘orderby=date&cat=” . $cat . “&order=ASC&posts_per_page=-1’); it is just puzzling that your other code (with the same error) alledegly does work (?) … Read more

Add class to current post in query_post

save the main current post id into a variable and compare it in the loop with the current post id; example: <?php $this_post = $post->ID; ?> <?php $temp_query = $wp_query; ?> <?php foreach(get_the_category() as $category) { $cat = $category->cat_ID; } query_posts(‘orderby=date&cat=” . $cat . “&order=desc&posts_per_page=-1’); while( have_posts() ) : ?> <span<?php if( $this_post == $post->ID … Read more

How to assign a post to a post parrent?

Posts & Pages are “built in” Custom Post Types. So something that was delivered as a pre-configuration when WP was installed. There’s also other built in stuff like Tags & Categories which are basically nothing other than custom taxonomies. And you’re lucky: You can simply use the API and add your own, hierarchical custom “post” … Read more

Script that gets the first tag of post and query all other posts with the same tag

the query expects the tag slug, not the tag name: $tag = $tag->slug . ‘ ‘; and there is an error in the query syntax; corrected: query_posts(‘tag=’.$tag.’&posts_per_page=-1′); edit: full code rearranged: $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $tag = $tag->slug; break; } query_posts(‘tag=’.$tag.’&posts_per_page=-1′); while (have_posts()) : the_post(); ?> <p><a href=”https://wordpress.stackexchange.com/questions/27106/<?php the_permalink(); … Read more

query_post problem

// Category should be ‘cat’ <?php $args = array( ‘cat’ => $cat, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘blog’, ‘post_status’ => ‘publish’ ); ?>

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