Linking Two Post Types

Scribu’s posts-to-posts is a great and simple plugin, I’m sure we can help you get it working. The basic usage is pretty straightforward. assuming your custom post types are named ‘place’ and ‘event’, the following code would go into your theme’s functions.php file: function my_connection_types() { p2p_register_connection_type( array( ‘name’ => ‘events_to_places’, ‘from’ => ‘event’, ‘to’ … Read more

Including categories in search results

I’m using this code in my search.php above the main loop: $search_term = explode( ‘ ‘, get_search_query( false ) ); global $wpdb; $select = ” SELECT DISTINCT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN (‘category’)”; $first = true; foreach ( $search_term as $s ){ … Read more

How to Check if a Page Exists by URL?

You could make a list of paths to check… $page_paths = array( ‘analysis/firstNamelastName’, ‘exercise/firstNamelastName’ ); Then check if there’s a page object for each of the page paths. foreach( $page_paths as $page_path ) { echo ‘<code>’ . $page_path . ‘</code> ‘ . PHP_EOL; if( ! $page = get_page_by_path( $page_path ) ){ echo ‘Does not exist.’ … Read more

Front-End Post Submission

<?php $postTitle = $_POST[‘post_title’]; $post = $_POST[‘post’]; $submit = $_POST[‘submit’]; if(isset($submit)){ global $user_ID; $new_post = array( ‘post_title’ => $postTitle, ‘post_content’ => $post, ‘post_status’ => ‘publish’, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_author’ => $user_ID, ‘post_type’ => ‘post’, ‘post_category’ => array(0) ); wp_insert_post($new_post); } ?> <!DOCTYPE HTML SYSTEM> <html> <head> <meta content=”text/html; charset=utf-8″ http-equiv=”Content-Type” /> <title>Untitled Document</title> </head> … Read more

display all posts in wordpress admin

It doesn’t, in the top right under screen options it says, Show on screen, you can set this to a max of 999 ( I have never tried 999 just fyi) and you can select all, then bulk actions—>edit—>apply. Also I think there are plugins that do this that use direct wpdb functions, so you … Read more

The next_posts_link() works only with original $wp_query

next_posts_link and previous_posts_link use the global $wp_query. function get_next_posts_link( $label = null, $max_page = 0 ) { global $paged, $wp_query; http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/link-template.php#L1523 That means you need to do something like this to get those to work correctly. $orig_query = $wp_query; $wp_query = new WP_Query($args); // the rest of your code $wp_query = $orig_query; If you are … Read more