Skip to content

Instantly share code, notes, and snippets.

View brianleejackson's full-sized avatar
✍️
Writing

Brian Jackson brianleejackson

✍️
Writing
View GitHub Profile
@brianleejackson
brianleejackson / woorkup.css
Last active February 3, 2023 02:52
woorkup custom CSS used with GeneratePress theme. Source: https://woorkup.com/generatepress-review/
html {-webkit-font-smoothing: auto;}
/*fonts*/
strong {color:#202020;}
/*no margin mobile*/
@media screen and (max-width: 768px) {
.no-margin-mobile {margin-bottom:0px;}}
/*links*/
#block-2 a {text-decoration:none;}
#block-2 {border: 1px solid rgba(0,0,0,.05);
box-shadow: 0 0 27px 0 rgb(214 231 233 / 52%);
@brianleejackson
brianleejackson / remove-slug-cpt-alternate.php
Last active November 14, 2021 10:52
Alternative way to remove the base slug from custom post type URL. Source: https://woorkup.com/wordpress-custom-post-type/
function bis_remove_cpt_slug($args, $post_type) {
if(in_array($post_type, array('artist'))) {
$args['rewrite'] = array('slug' => '/');
}
return $args;
}
add_filter('register_post_type_args', 'bis_remove_cpt_slug', 10, 2);
@brianleejackson
brianleejackson / wordpress-preview-cpt.php
Last active May 29, 2020 19:02
Enable custom post type WordPress preview. Source: https://woorkup.com/wordpress-custom-post-type/
//adds custom post type query var to preview links
function mycptname_cpt_previow_query_vars($link, $post) {
$custom_post_types = array('artist');
if(in_array($post->post_type, $custom_post_types)) {
return add_query_arg(['post_type' => $post->post_type], $link);
}
return $link;
}
add_filter('preview_post_link', 'mycptname_cpt_previow_query_vars', 10, 2);
@brianleejackson
brianleejackson / remove-slug-cpt.php
Last active June 1, 2023 11:41
Remove base slug from custom post type URL. Source: https://woorkup.com/wordpress-custom-post-type/
function na_remove_slug( $post_link, $post, $leavename ) {
if ( 'artist' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
@brianleejackson
brianleejackson / wordpress-block-editor-cpt.php
Last active May 29, 2020 19:02
Enable WordPress block editor support on custom post type. Source: https://woorkup.com/wordpress-custom-post-type/
'show_in_rest' => true,
add_action( 'init', 'your_prefix_register_post_type' );
function your_prefix_register_post_type() {
$args = [
'label' => esc_html__( 'artists', 'text-domain' ),
'labels' => [
'menu_name' => esc_html__( 'artists', 'your-textdomain' ),
'name_admin_bar' => esc_html__( 'Artist', 'your-textdomain' ),
'add_new' => esc_html__( 'Add artist', 'your-textdomain' ),
'add_new_item' => esc_html__( 'Add new artist', 'your-textdomain' ),
'new_item' => esc_html__( 'New artist', 'your-textdomain' ),
@brianleejackson
brianleejackson / footer-enqueue.php
Created January 10, 2018 16:50
Load CSS in footer with wp coupons plugin
location /avatar {
proxy_pass https://secure.gravatar.com$request_uri;
}
location / {
sub_filter 'https://secure.gravatar.com/avatar/' 'https://cdn.example.com/avatar/';
sub_filter_once off;
}
@brianleejackson
brianleejackson / gp-svg-logo.css
Created September 5, 2017 04:53
gp-svg-logo
.site-logo img {
width: 155px;
}