Get Image Having the ID [closed]

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.

Is it possible to restrict access to specific pages in the admin area based on the page slug?

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

echo esc_url( get_permalink($post->ID) + complete the ID’s url

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

How to Extend login session times to a Month

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

Use post ID in functions.php file adminside

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

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