Inserting into WP DB

Use wp_cron to run a job every hour. http://codex.wordpress.org/Function_Reference/wp_cron Use $wpdb->get_results to fetch data from your external table. Example: $q = “SELECT * FROM my_table”; $results = $wpdb->get_results($q, OBJECT); foreach ( $results as $result) { } Insert new CPT-posts using wp_insert_post() http://codex.wordpress.org/Function_Reference/wp_insert_post

How to apply order on custom taxonomy and custom meta key on custom post type

I think the simplest way would be to run the loop for each status and only output posts that match the current status: $statuses = array( ‘Active’, ‘Pending’, ‘Sold’ ); foreach( $statuses as $status ): echo $status; while( have_posts() ): the_post(); if( has_term( $status, ‘vr_listing_status’ ) ): the_title(); endif; endwhile; rewind_posts(); endforeach; A couple of … Read more

How to make a list of posts displaying them 5 by 5 with a “next posts” link?

I found the actual answer in a stackoverflow question. Quoted from the answer: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => $paged ); $wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; ?> <!– then the pagination … Read more

Split custom post list into two columns

You could count the number of items and insert </ul><ul> after 50%. Sample code, not tested: if ($postslist) { $count = 1; if($top) echo ‘<h4>’.$name.'</h4>’; echo ‘<ul>’; foreach ( $postslist as $post ) { echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title($post->ID).”</a></li>”; if ( 0 === $count % 10 ) echo ‘</ul><ul>’; $count += 1; } echo ‘</ul>’; } And … Read more

create functions based on array values

Can you use the __call PHP class functionality? http://www.php.net/manual/en/language.oop5.overloading.php#object.call You could use __call in your class and call your function for grabbing the page types and check them against the $name (first) argument and running custom code against it. For instance: __call ($name, $args) { $types = array (‘type_a’, ‘type_b’, ‘type_c’); if (in_array($name, $types) { … Read more

Textarea type on one field custom add_meta_box?

i got the solutions, array( ‘shortdesc’, ‘shortdesc’ , ‘textarea’), and add new function for text_area: function text_area ( $args ) { global $post; // adjust data $args[2] = get_post_meta($post->ID, $args[0], true); $args[1] = __($args[1], ‘fp’ ); $label_format=”<label for=”%1$s”>%2$s</label><br />” . ‘<textarea style=”width: 95%%;” name=”%1$s”>%3$s</textarea><br /><br />’; return vsprintf( $label_format, $args ); }