Exclude pages by menu order

Declare the following function in your functions.php function wpse58346_wp_list_pages( $pages, $r ) { foreach( $pages as $key => $page ) { if ( 50 < $page->menu_order ) unset($pages[$key]); } return $pages; } Now before calling wp_list_pages() apply a filter as follows add_filter(‘get_pages’, ‘wpse58346_wp_list_pages’, ”, 2); And after you have called wp_list_pages() you can remove the … Read more

How to make a page unsearchable in blog search?

function hide_from_search($qry) { if (is_search()) $qry->query_vars[‘post__not_in’][] = xXx; return $qry; } add_filter(‘pre_get_posts’,’hide_from_search’); The xXx is the ID number of the page to exclude. Just read it out of the URL on the backend. When you are editing the page you want to exclude look at the URL bar. You should see “post=xXx” in there.

Dynamic href link to Contact Page

If the contact page is identified solely by the associated template, you can query for a page with the template name in meta key _wp_page_template: $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => 1, ‘meta_query’ => array( array( ‘key’ => ‘_wp_page_template’, ‘value’ => ‘contact_template.php’ ) ) ); $contact_page = new WP_Query( $args ); if( ! … Read more

Only Display a Featured Image on First Post Page

Use the global $page, which holds the current page number. // Somewhere near the top if ( $GLOBALS[‘page’] === 1 && $image_data = get_post_thumbnail_id() ) { if ( $image_data = wp_get_attachment_image_src( $image_data, ‘full’ ) ) { if ( $image_data[1] >= 500 ) the_post_thumbnail( ‘top-post’ ); } } // Further down. $image_data still exists, no need … Read more

How to remove only pages from Admin Bar?

The menu bar is all controlled by an object instantiated as $wp_admin_bar. I think this is what you want: function remove_page_menu_wpse_104826() { global $wp_admin_bar; // var_dump($wp_admin_bar); // debug; uncomment and look at the bottom of the page for the big mess $wp_admin_bar->remove_menu(‘new-page’); } add_action(‘wp_before_admin_bar_render’, ‘remove_page_menu_wpse_104826’, 1);

loading a javascript on a WP PAGE

You’ll find a file called functions.php in your theme folder. Open it and add the following snippet: function wpse_109027_enqueue_js() { wp_enqueue_script( ‘custom-script’, get_stylesheet_directory_uri() . “https://wordpress.stackexchange.com/js/script.js”, array( ‘jquery’ ) ); } add_action( ‘wp_enqueue_scripts’, ‘wpse_109027_enqueue_js’ ); wp_enqueue_script is used to add javascript files. The array(‘jquery’) part means that WordPress should load jQuery before loading your javascript file. … Read more

Remove comment section from new page

If you want to be rid of comments on your site, one option is to remove the code from your theme files. You would need to search single.php, home.php, page.php, etc. within wp-content/themes/*your-active-theme* and find: <? php comments_template(); ?> Remove that and the comments section should disappear. NOTE: this change will be undone if you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)