Show links to child pages on both parent AND child pages

This seemed to work nicely for me; <?php $children = get_pages(‘child_of=”.$post->ID); if( count( $children ) != 0 ) { $id = $post->ID; } else { $id = $post->post_parent; } $args = array( “post_type’ => ‘page’, ‘post_parent’ => $id, ‘posts_per_page’ => -1 ); $system_query = new WP_Query($args); if ($system_query->have_posts()) : while ($system_query->have_posts()) : $system_query->the_post(); ?> <!– … Read more

Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more

Find all posts via SQL beginning with A of type B

Try this.. SELECT * FROM $wpdb->posts p INNER JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id=tt.term_taxonomy_id inner join $wpdb->terms t on t.term_id=tt.term_id and t.slug=’igralni’ WHERE p.post_title LIKE ‘А%’ AND p.post_type=”filmi-i-serialii” AND p.post_status=”publish”

How to add a prefix to existing custom fields over MYSQL query?

important: backup your database first! Assuming your table prefix is ‘wp_’, this query will change the custom field names: update wp_postmeta set meta_key = ‘booking_testfield’ where meta_key = ‘testfield’; NB: this also assumes that the custom field name is unique to your application, i.e. it isn’t used by another post type. If it is possible … Read more

How to callback custom field text

Your text is already in the array $m_slider_custom, from this line: $m_slider_custom = get_post_custom($post->ID); If you just want the specific key feat_music you can use get_post_meta(): echo get_post_meta( $post->ID, ‘feat_music’, true ); Another, unrelated thing- I suggest spending some time with the Codex and cleaning up your URLs and paths. For example, this: get_option(‘siteurl’) . … Read more

Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more

How to use Greek characters/letters in a query?

This is the loop I’ve created to display post’s matching criteria on empty page: // get results $the_query = new WP_Query( ‘meta_key=apaitei_logariasmo_facebook&meta_value=Ναι’ ); // The Loop if( $the_query->have_posts() ) while ( $the_query->have_posts() ) { $the_query->the_post(); echo ‘<h3>’; the_title(); echo ‘</h3>’; the_content(); } wp_reset_postdata(); It works. Look at the image: Note: my site’s language is English … Read more

New WordPress WP Query using posts from certain categories

There are some errors in your code, you have to change: $the_query -> have_posts() to $the_query->have_posts() $the_query -> the_post() to $the_query->the_post() WP_Query array(…) to WP_Query(array(…)) ‘showposts=6’ to ‘posts_per_page’ => 6 Try this instead $the_query = new WP_Query( array( ‘category_name’ => ‘portfolio’, ‘posts_per_page’ => 6 ) ); while ($the_query->have_posts()) : $the_query->the_post(); the_post_thumbnail(); endwhile;

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