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 / 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 );
}
@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 / 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 / Retrieve the permalink for a page by slug
Created September 18, 2019 10:26
Scenario : You would normally grab a page link via its ID but in the case that you had a localhost which install and an online install the ID was different, how you can link the page? Solutions 3: Retrieve the permalink for a page by slug
@vbaimas
vbaimas / Retrieve the permalink for a page by title
Created September 18, 2019 10:20
Scenario : You would normally grab a page link via its ID but in the case that you had a localhost which install and an online install the ID was different, how you can link the page? Solution 2 : Retrieve the permalink for a page by title
@vbaimas
vbaimas / Retrieve the permalink for a page by name
Last active September 18, 2019 10:22
Scenario : You would normally grab a page link via its ID but in the case that you had a localhost which install and an online install the ID was different, how you can link the page? Solution 2 : Retrieve the permalink for a page by name
@vbaimas
vbaimas / Changing the search string in WordPress search form
Last active January 4, 2019 16:12
In case you want to change the default word “Search” in the Search Button, into something different, this snippet will allow to change it.
/*/
/* Change Search Button Text
/*/
add_filter('get_search_form', 'my_search_form');
function my_search_form($text) {
$text = str_replace('value="Search"', 'value="ok"', $text); //set as value the text you want
return $text;
}
@vbaimas
vbaimas / _mixins.scss
Created August 27, 2018 19:39 — forked from garyharan/_mixins.scss
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@vbaimas
vbaimas / sass-margin-padding.scss
Last active August 27, 2018 18:44 — forked from jbrz0/sass-margin-padding.scss
Sass mixin for quickly adding padding and margins
//Padding mixin
@mixin padding($top, $right, $bottom, $left) {
padding-top: $top;
padding-right: $right;
padding-bottom: $bottom;
padding-left: $left;
}
//Margin mixin
@mixin margin($top, $right, $bottom, $left) {
margin-top: $top;
@vbaimas
vbaimas / functions.php
Last active July 1, 2018 23:39
Create a full width attachment image in WordPress using Custom Post Types and Advanced Custom Fields
add_action( 'after_setup_theme', 'setup' );
function setup() {
add_theme_support( 'post-thumbnails' ); // This feature enables post-thumbnail support for a theme
add_image_size( 'single-workspace', 9999, 840, false );
}