List child pages within page template
The ID of the current page is available via the global $post variable, so to get the ID use: global $post; $currentPage = $post->ID; Then you can use $currentPage in your query 🙂
The ID of the current page is available via the global $post variable, so to get the ID use: global $post; $currentPage = $post->ID; Then you can use $currentPage in your query 🙂
Put the below code in your functions.php and then you can use this [get_image_by_id id=”your-image-id”] shortcode to get the image add_shortcode( ‘get_image_by_id’, ‘the_dramatist_get_image_by_id’); function the_dramatist_get_image_by_id($atts) { return wp_get_attachment_image($atts[‘id’]); } Here “your-image-id” is numeric ID of the image. Hope that helps.
So following from the comment discussion, a sufficient answer on another StackEx question goes like this: 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(’21’,’22’,’23’); } } The only part that’s terribly important to us is the array of post IDS. The problem is … Read more
As far as i know there is no arguments array key name ‘post_category’ in WP_Query . Insted of ‘post_category’ use either ‘category__in’ => array( 2, 6 ) or category_name’ => ‘staff’. And also for the id case use echo get_the_ID() … to print the post id
The most easy way to append something to the end of URLs and process it in WP are rewrite endpoints. It makes it easy to target specific kind of URLs and generally it is unlikely to explode everything, like many of rewrite modifications do.
As stated in the documentation, The $current_user global may not be available at the time this filter is run. So you should use the $user global or the $user parameter passed to this filter. function my_login_redirect( $redirect_to, $request, $user ) { // Don’t modify the redirect on error. if( wp_is_error( $user ) ) return $redirect_to; … Read more
The best approach, from my point of view, is to use add_query_arg() function: $only_conent_url = add_query_arg( array( ‘content-only’ => 1 ), get_permalink( $post->ID ) ); And then you can escape it if you need: esc_url( $only_conent_url ); add_query_arg() takes the URL passed as second paramenter and append a properly formatted query string built from the … Read more
No there isn’t, and it isn’t necessary. Post type names are their own unique identifiers. The primary reason there are no numeric IDs is because post types are registered on every page load in PHP, no table exists in the database for them, which means no row IDs. So there is no use for a … Read more
By default the login cookie lasts for 14 days if you tick ‘remember me’ 48 hours if you don’t So as a short term fix you probably want to tick ‘remember me’, and to extend that to 30 days you can add an auth_cookie_expiration filter e.g. function auth_cookie_expiration_30_days( $seconds, $user_id, $remember_me ) { if ( … Read more
It depends on, where you are calling these functions. That is the point, where you enter the var into the function. First, remove the global $post from your functions.php! It makes no sense there! In the functions.php you declare the functions, not call them! I assume, you call your function in some template. So the … Read more