Skip to content

Instantly share code, notes, and snippets.

View brianleejackson's full-sized avatar
✍️
Writing

Brian Jackson brianleejackson

✍️
Writing
View GitHub Profile
location / {
sub_filter 'https://secure.gravatar.com/avatar/' 'https://cdn.example.com/avatar/';
sub_filter_once off;
}
location /avatar {
proxy_pass https://secure.gravatar.com$request_uri;
}
@brianleejackson
brianleejackson / footer-enqueue.php
Created January 10, 2018 16:50
Load CSS in footer with wp coupons plugin
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 / 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,
@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-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-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 / 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 / generatepress-author-sidebar-widget.html
Last active June 12, 2020 19:19
GeneratePress author sidebar widget box as seen here: https://woorkup.com/
<center><img src="https://domain.com/bio-pic.png" class="no-lazy" width="175" height="175" alt=""></center>
<div style="background:#FAF3D4; color: #5d5b54; margin: 15px 0; padding: 1em 1em; border-width: 0 0 0 12px;"><strong style="font-size:19px;">Hi there, I'm {name}. <a href="https://twitter.com/username" target="_blank" style="border-bottom:0px; color:#504e48;" rel="noopener noreferrer"><i class="fa fa-twitter fa-2x;" aria-hidden="true"></i></a></strong><br
/><span style="line-height:23px;font-size:18px;">Write something about you. <strong><a style="color:#504e48; border-bottom: 2px solid rgba(80, 78, 72, 0.2);" href="https://domain.com/about/">Read more</a></strong></span></div>