Would a “hub” page work better as a page or a post?

For things like that a page is better option, because you can make use of custom page templates and also because pages are a better place for inner secondary queries. As example, if you want to use pagination for secondary queries, alongside next_posts_link() and previous_posts_link(), both those functions check if ( ! is_single() ) to … Read more

Page templates in subdirectories and auto generator

Instead of having a page template for all of them, have a single page template and use get_template_part to pull in the parts unique to each page. So instead of: update_post_meta($new_page_id, ‘_wp_page_template’, $page_filename); You’d have: update_post_meta( $new_page_id, ‘_wp_page_template’, ‘newpagetemplate.php’ ); update_post_meta( $new_page_id, ‘sagive_page_type’, $page ); Then inside your new page template: $type = get_post_meta( get_the_id(), … Read more

Change Author Name to Sitename on Frontend

You could modify it through the the_author filter: /** * Set the author name as the site title. */ ! is_admin() && add_filter( ‘the_author’, function( $author ) { return get_bloginfo( ‘name’ ); } ); where we change the author name to the site name on the frontend with the help of the get_bloginfo() function.

Display pages in alphabetical order

Filter pre_get_posts is used for modifying the query from theme or plugin. This hook is called after the query variable object is created, but before the actual query is run. Codex documentation of pre_get_posts Although this filter is very handy and useful, we need to be very careful using it. We should very careful about … Read more

Add posts of a certain category to a page

Create a page template and use wp_query to target the category you want to display $args = array(‘category_name’ => ‘your category name’,); WP_Query will help you with all sorts of options for what posts are returned and get displayed by your loop. Here is an example of a page template, (this is based on the … Read more

Creating custom page template

Assuming that you’re on a page template or a custom page template, the first thing you want to do is grab the current page ID, then use that ID to grab the children. Once you have the children, display the content for those children. Try using get_children(); You can also try get_page_children but for my … Read more

Need 404 behaviour for blank parent page

In functions.php function productsPageRedirect_404() { global $post; if( is_page(‘products’) ) { global $wp_query; $wp_query->set_404(); status_header(404); } } add_action( ‘wp’, ‘productsPageRedirect_404’ );