wp_insert_post if page doesn’t exist under current page

$args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘post_parent’ => $post->ID, ); $children= new WP_Query( $args ); $seasonepisode = array( ‘post_title’ => $episodetitle, ‘post_content’ => ‘Some Content’, ‘post_status’ => ‘publish’, ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘page_template’ => ‘template-songlist.php’ ); if ( $children->have_posts() ){ while ( $children->have_posts() ) { $children->the_post(); if(get_the_title() != $episodetitle){ wp_insert_post($seasonepisode); … Read more

WP_Query: “post_parent” and “post_type” combination returning strange results

It turns out I have an errant pre_get_posts function: function fgw_parents_only( $query ) { if ( ! is_admin() && $query->is_post_type_archive( ‘project’ ) ) { $query->set( ‘post_parent’, 0 ); $query->set( ‘posts_per_page’, -1); } } add_action( ‘pre_get_posts’, ‘fgw_parents_only’ ); Not exactly sure why is_post_type_archive caused this to show up on a single-project.php template, but I managed to … Read more

WordPress count child posts of each parent custom post type and use in json array for google maps jquery plugin

First of all you should alway separate php from javascript. Generally talking, it’s a bad practise mix them, and specifically to WordPress, it also force you to add javascript inline instead using the WordPress proper way: using wp_enqueue_script. When you need pass variables from PHP to javascript, the proper WordPress way to do it is … Read more

Display post taxonomies tree

What about: $taxName = “tvr_amenity”; $terms = get_terms($taxName,array(‘parent’ => 0)); foreach($terms as $term) { echo ‘<a href=”‘.get_term_link($term->slug,$taxName).'”>’.$term->name.'</a>’; $term_children = get_term_children($term->term_id,$taxName); echo ‘<ul>’; foreach($term_children as $term_child_id) { $term_child = get_term_by(‘id’,$term_child_id,$taxName); echo ‘<li><a href=”‘ . get_term_link( $term_child->name, $taxName ) . ‘”>’ . $term_child->name . ‘</a></li>’; } echo ‘</ul>’; }

How can I paginate image attachments in a post?

I doubt you could paginate within a post display. It would be more effective to display all the image attachments at the page load, and have a script do the pagination. You can find a lot of them on such sites: http://www.themeflash.com/30-powerful-jquery-slideshow-sliders-plugins-and-tutorials/ You need to be able to edit your template files, specifically the header … Read more

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