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 / back-next-generatepress.css
Last active August 21, 2020 04:05
Replace page numbers in GeneratePress with next and back. Seen here: https://woorkup.com/
.nav-links .page-numbers:not(.next):not(.prev) {
display: none;
}
@brianleejackson
brianleejackson / scroll-sticky-widget-no-jquery.css
Last active October 16, 2020 14:28
Scroll sticky sidebar WordPress widget with no jQuery
@media (min-width: 769px) {
.site-content {
display: flex;
}
.inside-right-sidebar {
height: 100%;
}
.inside-right-sidebar aside:last-child {
position: -webkit-sticky;
position: sticky;
@brianleejackson
brianleejackson / progress-bars-no-jquery.css
Last active August 18, 2020 07:33
Progress bars with no jQuery as seen here: https://pennybros.com/
/*Progress bar CSS*/
.meter {
height: 30px;
position: relative;
background: #f3efe6;
border-radius:3px;
overflow: hidden;
margin: 5px 0 5px 0;
}
.meter span {
@brianleejackson
brianleejackson / rankmath-wp-coupons-schema-breadcrumb.php
Created June 26, 2020 20:52
RankMath WP Coupons schema breadcrumb
//filter coupon post breadcrumbs
add_filter('rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
if(is_singular('coupon')){
//change archive page name
$crumbs[count($crumbs)-2][0] = "Lifetime Deals";
}
return $crumbs;
}, 10, 2);
@brianleejackson
brianleejackson / exclude-logo-lazy-load-generatepress.php
Last active June 29, 2021 18:59
Exclude logo (desktop and mobile) from lazy load in GeneratePress theme with Perfmatters plugin. Source: https://perfmatters.io/docs/lazy-load-wordpress/ *Update* This is no longer needed as you can add class exclusions in Perfmatters.
//add no-lazy class to primary logo
function wpd_generate_logo_output($output, $logo_url, $html_attr) {
//add our no-lazy class
$html_attr = str_replace('class="', 'class="no-lazy ', $html_attr);
//logo output
printf(
'<div class="site-logo no-lazy">
<a href="%1$s" title="%2$s" rel="home">
@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>
@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;
}