WordPress Access allowed to fewer pages till user logs in

You could try the Members plugin to restrict access to certain pages, very handy. In the menu section you can check if user is logged in, and show extra menu items if logged in by adding code similar to this in your template if ( is_user_logged_in() ) { wp_nav_menu( array( ‘theme_location’ => ‘logged-in-menu’ ) ); … Read more

Customising the search function?

You can use pre_get_posts hoot to filter the search query to selected sectors only, something like this: function Search_with_in_a_tax( &$query ) { if ( is_search() && isset($_GET[‘sector_array’])) { $tax_query = array( array( ‘taxonomy’ => ‘news’, ‘terms’ => $_GET[‘sector_array’], ‘field’ => ‘term_id’, ) ); //turn it into a WP_Tax_Query object $tax_query = new WP_Tax_Query($tax_query); $query->set(“tax_query”, $tax_query); … Read more

Mass update excerpt

Issue 1: creating the excerpt data This should be fairly easy to do directly with SQL. UPDATE wp_posts AS post INNER JOIN wp_posts AS attachment ON attachment.post_type=”attachment” AND post.ID = attachment.post_parent SET post.post_excerpt = CONCAT(‘<img src=”‘, attachment.guid,'” />’) WHERE post.post_excerpt=””; This is obviously a “one-time fix” that implies you have access to the database. If … Read more

Compare post-IDs within WP_Query? (Less than / Greater than)

I ended up using something like this: function filter_where( $where=”” ) { global $post, $prev_next; $the_ID = $post->ID; $where .= ” AND wp_posts.ID “; $where .= $prev_next==’next’ ? “< $the_ID” : “> $the_ID”; return $where; } add_filter( ‘posts_where’, ‘filter_where’ ); $nextProjQuery = new WP_Query( $filtered_query_args ); remove_filter( ‘posts_where’, ‘filter_where’ );