Adding Author and Updated Schema Markup to WordPress Static Pages

Best practice would be to structure your schema so that the author is your organizations. Under Schema, an itemprop=”author” can be either a Person or an Organization. If you do have another content item like a blog post, it ought to have an author listed. Having an author assigned can boost your pagerank. Author information … Read more

Redirect to page list when page published

I have the below code which works as expected if anyone else is looking for similar. add_action( ‘publish_page’, ‘redirect_user_page_list’, 10, 3 ); function redirect_user_page_list() { if( is_user_logged_in() ) { $user = wp_get_current_user(); $role = ( array ) $user->roles; if ( ‘role_slug’ == $role[0] ) { $url=”url to redirect to”; wp_redirect($url); exit; } } }

Remove ID page from wp_count

This should work for you to exclude via ID: //replace the 3,8 with your page ids <?php $args=array( ‘post__not_in’ => array(3,8), ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ); query_posts($args); ?> If you want to exclude via page title you can do this <?php $exclude1 = get_page_by_title(‘Sample Page Title’); ?> <?php $exclude2 = get_page_by_title(‘Sample Page Title … Read more

I Changed the Menu Order, But the Page Order Didn’t Change on Front Page

By default, posts and pages are sorted after the date. If you want sort pages by “order” field, which is visible on edit page, you have to set orderby parameter: add_action(‘pre_get_posts’, ‘change_order’); function change_order($query) { if ( is_front_page() || is_home() ) { $query->set( ‘orderby’, ‘menu_order’ ); $query->set( ‘order’, ‘ASC’ ); } return $query; } Put … Read more

Show own shortcode data on each page

Best way to achieve the desired functionality is to use post_meta / custom field. add_shortcode (‘cities’, ‘show_cities’); function show_cities(){ /* Create a custom field ‘city’ to save city name in page editor */ $city = get_post_meta( get_the_id(), ‘city’, true ); return $city; } Using an array can also do the work as under: add_shortcode (‘cities’, … Read more