Display all submenus

Ok, the problem in my solution was the use of $menu_item->ID instead of $menu_item->object_id. So the full correct logic is like so: function print_sub_menus() { global $post; // get current page $post_id = $post ? $post->ID : -1; $has_post_parent = $post && $post->post_parent; $top = $has_post_parent ? array_pop( get_post_ancestors($post_id) ) : $post_id; // get all … Read more

Add exception to WP Mobile Detector

By means of preg_match and the like you can only write rules for specific devices (in your case the GT-P5100). What you want to do, however, is to affect only your device (meaning: not all Galaxy Tabs). I’d vote for setting a cookie and act upon it’s particular value: setcookie(‘no_mobile_theme_please’, 1, time()+60*60*24*30, “https://wordpress.stackexchange.com/”, $_SERVER[‘SERVER_NAME’], false, … Read more

only display Pages which have children

Do you want to list only the pages with children? I’m not sure to understand well what you want to do 🙁 If I’m right, you’ll have to do something like this with get_pages() and generate your listing manually after: // First get all pages $pages = get_pages(); // Then, get page IDs if ($pages) … Read more

How to show the image caption on custom post type …?

You should be able to use the caption from post_excerpt of the WP_Post object. $the_imgs = get_custom_field(‘gallery_img:to_array’); foreach( $the_imgs as $img ) { list( $url, $width, $height ) = wp_get_attachment_image_src( $img, ‘thumbnail’ ); $img_post = get_post( $img ); echo ‘<img src=”‘ . $url . ‘” width=”‘ . $width . ‘” height=”‘ . $height . ‘”> … Read more

Custom fields: my custom checkbox area doesn’t seem to work

I went through all this yesterday! According to the codex there must be a post id given to current_user_can to check ‘edit_post’, so your capability check should be: if( !current_user_can( ‘edit_post’, $post_id ) ) return; Also, your final two lines should be more like this: $chk = isset( $_REQUEST[‘page_title_off’] ) ? ‘on’ : ‘off’; update_post_meta( … Read more

WordPress Theme – jQuery JavaScript Library Issue

Not entirely sure what you’re asking but you have to include and register scripts and then enqueue what you require like:- <?php wp_enqueue_script(‘jquery’); ?> (Place immediately before <?php wp_head(); ?>). Which is included with WordPress incidentally. You can read more on wp_enqueue_script for more information on how to use this in your theme. Edit An … Read more

Create a short code that inserts js

Put the script into an external file, set the selector there and enqueue it from your shortcode: if(! function_exists (‘aisis_toc’) ) { function aisis_toc() { if ( ! is_singular() ) return; wp_enqueue_script( ‘jquery-toc’, plugins_url( ‘js/jquery-toc.js’, __FILE__ ), array ( ‘jquery’ ), NULL, TRUE); return; } }