Modify loop but keep the original query, what am I doing wrong?

You can’t concatenate an array onto query_string like that. See Digging Into WordPress’s post about looping for the right format. Alternately, you can use array_merge() like on the query_posts Codex page. Consider using wp_reset_query() after your loop. Sometimes you’ll also see people save the original $query_string to a new variable, modify $query_string, and then reset … Read more

Single-page wordpress theme navigation

I’ve done a few templates that essentially are on one page. I used this code as the starting block for all of them: <?php $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array(‘post_type’ => ‘page’,’posts_per_page’ => -1)); foreach ($all_wp_pages as $value){ $post = get_page($value); $slug = $post->post_name; $title = $post->post_title; $content = apply_filters(‘the_content’, $post->post_content); }; ?> It … Read more

How to write sql query to get the posts from a custom taxonomy term name

@Sisir linked you to the appropriate place, if you had read the question/answer and the linked Codex documentation you’d have seen that you could do something like the following: $args = array( ‘post_type’ => ‘dealers’ ‘tax_query’ => array( array( ‘taxonomy’ => ‘state’, ‘field’ => ‘slug’, ‘terms’ => array(‘bob’,’angela’,’john’,’smith’,’jan’,’doe’,’etc…’) ) ) ); $query = new WP_Query( … Read more

How to only publish posts with image in it

I found and modified a chunk of code found here: http://www.wprecipes.com/wordpress-tip-detect-if-a-post-has-at-least-one-image. <?php while ( have_posts() ) : the_post(); $content = $post->post_content; $searchimages=”~<img [^>]* />~”; preg_match_all( $searchimages, $content, $pics ); $iNumberOfPics = count($pics[0]); if ( $iNumberOfPics > 0 ) { //your loop content goes here } endwhile; ?> I think this just looks for images entered … Read more

Question about querying posts

Here’s a very basic example that should do what you need it to do. Basically, we get all of the posts in your custom post type, then loop through them individually. When we find the one set with “promote_to_homepage,” we render some display and exit the loop: // Query for all posts in the post … Read more

query_posts pagination will always show identical content

Don’t use query_posts! As Eugene pointed out, you omitted the paged variable. However, even with that in you can get unexpected behaviour. As illustrated by the various questions we get on query_posts and pagination: query_posts and pagination, still stuck after much research Pagination throws 404 Pagination throws 404 error on custom taxonomy archive pages

Getting all ID’s matching a title in a custom post type

Just change the $args array to this: //Let’s say you’re searching the posts with the title ‘The searched post’: $pages = array(); $args1 = array( ‘s’ => ‘The searched post’, ‘post_type’ => ‘course-manager’, ‘posts_per_page’ => -1 ); query_posts( $args1 ); Your query_posts will return all the posts with the title alike ‘The searched post’.

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