Skip to content

Instantly share code, notes, and snippets.

View vbaimas's full-sized avatar
🎯
Focusing

Vasilis Baimas vbaimas

🎯
Focusing
View GitHub Profile
@vbaimas
vbaimas / Get the permalink for a page by parent,child
Created September 18, 2019 10:26
Scenario : If you want to get the permalink using the method with child-page, then you need to pass the full slug. So, in this case we have a child page "about" with a parent pages which called "skills".
@vbaimas
vbaimas / Get the link to custom post type archive page
Last active September 18, 2019 10:29
Scenario : If you have a custom posts loop and in the bottom you want to add "View all" link, then how you should lead to the page with all posts that type?
<a href="<?php echo get_post_type_archive_link ( 'your_post_type' ) ?>"</a>
@vbaimas
vbaimas / Enable Yoast SEO only in administrator role and in specific content types
Created January 17, 2020 15:21
Disable the Yoast SEO meta box and the page analysis columns for all roles other than administrator and also disable the Yoast SEO meta box in the content types like "post", "page" and "custom post type".
// Returns true if user has specific role
function {your_prefix}_check_user_role( $role, $user_id = null ) {
if ( is_numeric( $user_id ) )
$user = get_userdata( $user_id );
else
$user = wp_get_current_user();
if ( empty( $user ) )
return false;
return in_array( $role, (array) $user->roles );
}