Multiple is_page() in page.php

You can pass an array of IDs to is_page instead of using multiple is_page: if( is_page( array( 11, 22, 33, 44 ) ) ) { // Your code } Also, if you are using it in a loop, you should consider this note: Due to certain global variables being overwritten during The Loop, is_page() will … Read more

Return current page type

You need your own helper function which will return you what you need. It could be like this one: function wpse8170_loop() { global $wp_query; $loop = ‘notfound’; if ( $wp_query->is_page ) { $loop = is_front_page() ? ‘front’ : ‘page’; } elseif ( $wp_query->is_home ) { $loop = ‘home’; } elseif ( $wp_query->is_single ) { $loop … Read more

How to add jQuery script to an individual page?

Although @s_ha_dum is correct you WILL need to use jQuery no conflict within WordPress the original question is left unanswered. I have this code which I want to add into a specific page of mine. There are a couple of ways to do this Based on Page name/slug WordPress in theme’s functions.php This method uses … Read more

How can I store page ID in a post instead of other selected permalink?

Add that to your functions.php: function wp_link_query_mod ( $results ){ if( count( $results ) ){ for( $i=0; $i<count($results); $i++ ){ $results[$i][‘permalink’] = wp_get_shortlink( $results[$i][‘ID’] ); } } return $results; } add_filter(‘wp_link_query’, ‘wp_link_query_mod’); This hook is only usable since WP 3.7, if you have an earlier version then there is an alternative but it would mean … Read more

Restrict admin access to certain pages for certain users

This code seems to work well for me (in functions.php): $user_id = get_current_user_id(); if ($user_id == 2) { add_filter( ‘parse_query’, ‘exclude_pages_from_admin’ ); } function exclude_pages_from_admin($query) { global $pagenow,$post_type; if (is_admin() && $pagenow==’edit.php’ && $post_type ==’page’) { $query->query_vars[‘post__not_in’] = array(‘123′,’234′,’345’); } }

How to add a specific widget to only 1 page?

It depends on where you want to show the widget. Let’s start with the widget area (sidebar) registration: add_action( ‘wp_loaded’, ‘wpse_76959_register_widget_area’ ); function wpse_76959_register_widget_area() { register_sidebar( array ( ‘name’ => __( ‘Widgets on page Sample Page’, ‘theme_textdomain’ ), ‘description’ => __( ‘Will be used on a page with a slug “sample-page” only.’, ‘theme_textdomain’ ), ‘id’ … Read more

get_pages() not ordering as it should

This is indeed an error, and probably caused by the child_of argument. Because child_of requests the whole subtree of the given page (not only the direct children, but also children of those children and so on), WordPress first queries for all the pages and then selects a subset of those pages. The first query respects … Read more

Get top level page parent title

Found this way: if ( 0 == $post->post_parent ) { the_title(); } else { $parents = get_post_ancestors( $post->ID ); echo apply_filters( “the_title”, get_the_title( end ( $parents ) ) ); } Anyone got a better way please answer.

How do I convert a page’s title to lower case?

lowercasing the title If I’m understanding you correctly, you should be doing: strtolower(get_the_title()); or print strtolower(get_the_title()); if you want to display it. Below is an explanation as to why. the_title() vs. get_the_title() The function the_title() prints the current post’s title unless you pass false as its third argument. Unless you call it like: $title = … Read more

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