Skip to content

Instantly share code, notes, and snippets.

@WordBits
WordBits / snippet.php
Created April 17, 2020 15:09
A snippet of code for adding an H1 tag to the top of the blog listing page on Astra sites.
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/add-h1-to-blog-listing-page/
// Created by: Liam Dempsey
?>
<?php function prefix_your_function() {
if ( is_home() ) {
echo '<h1>Hey everyone!</h1>';
@WordBits
WordBits / snippet.php
Created April 1, 2020 19:20
Maybe this will work?
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/extend-public-post-preview/
// Created by: Liam Dempsey
?>
<?php
add_filter( 'ppp_nonce_life', 'my_nonce_life' );
function my_nonce_life() {
return 60 * 60 * 24 * 5; // 5 days
}
@WordBits
WordBits / snippet.php
Created December 8, 2019 21:32
Code I got from Joe to do stuff.
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/paginate-pages/
// Created by: Liam Dempsey
?>
<?php
function paginate_child_pages( $post ) {
$page_id = $post->ID;
$args = array(
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/display-the-last-updated-date-of-posts/
// Created by: Liam Dempsey
?>
<?php
function wpb_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
@WordBits
WordBits / snippet.php
Created May 22, 2019 19:33
Double-checking functionality and integrations
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/a-fun-bit-of-code/
// Created by: Liam Dempsey
?>
<?php
// Some fun filler stuff
?>
@WordBits
WordBits / snippet.php
Created February 6, 2019 15:22
Extend the life of the Public Post Preview plugin to 10 days.
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/extend-the-public-post-preview-plugin/
// Created by: Lauren Pittenger
?>
<?php
/**
* Public post preview pugin: extend expiration to 10 days
*/
add_filter( 'ppp_nonce_life', 'fans4thecure_nonce_life' );
@WordBits
WordBits / snippet.php
Created February 1, 2019 18:52
Change [...] to Read More » on Genesis sites
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/change-to-read-more/
// Created by: Liam Dempsey
?>
<?php
//* Modify the Genesis content limit read more link
add_filter( 'get_the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
return '... <a class="more-link" href="' . get_permalink() . '">[Read More &raquo;]</a>';
@WordBits
WordBits / snippet.php
Created September 30, 2018 03:08
This snippet allows you to add GTM (or other) code snippets to a site without having to guess which header/footer files are bing used by a theme. Convenience snippet for use in child themes where the parent theme uses multiple header/page/footer files. Instead of figuring out by trial and error which one is being used, simply drop this code into…
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/add-gtm-ga-other-code-to-site-header-and-or-body/
// Created by: Fernando Ayala
?>
<?php
function hook_insert_in_header() {
/* Example for Google Tag Manager
Simply replace the code snippet below with the snippet that needs to be
in the header of your site.
@WordBits
WordBits / snippet.php
Created September 27, 2018 18:06
This will print /blog/post-name instead of /post-name for posts
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/add-url-prefix-for-blog-posts/
// Created by: Mark Vi
?>
<?php
/**
* Add new rewrite rule
**/
function create_new_url_querystring() {
@WordBits
WordBits / snippet.php
Created September 24, 2018 16:35
Auto login after register user in wordpress and redirect to a home page.
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/auto-login-after-registration/
// Created by: Ravi Patel
?>
<?php
function auto_login_new_user( $user_id ) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
wp_redirect( home_url() );