Skip to content

Instantly share code, notes, and snippets.

generatepress

Block or report user

Report or block generatepress

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@generatepress
generatepress / gist:179434f97888af190ee1d65e36402962
Created May 5, 2019
Make Dispatch Custom Post Navigation work with any custom post type
View gist:179434f97888af190ee1d65e36402962
<div id="post-nav">
<?php global $post;
$prevPost = get_previous_post(false);
$post_type = get_post_type();
if($prevPost) {
$args = array(
'posts_per_page' => 1,
'include' => $prevPost->ID,
'post_type' => $post_type,
View gist:bb5b5b84350f725ba3deaf5ee126c4cc
add_filter( 'generate_logo_href', function( $url ) {
if ( function_exists( 'pll_home_url' ) ) {
return pll_home_url();
}
return $url;
} );
@generatepress
generatepress / gist:4f76e08e7198841bef15f9347afe7454
Created Mar 26, 2019
Don't show Elements if Polylang language doesn't match
View gist:4f76e08e7198841bef15f9347afe7454
function generate_elements_ignore_languages( $post_id ) {
if ( function_exists( 'pll_get_post_language' ) && function_exists( 'pll_current_language' ) ) {
$language = pll_get_post_language( $post_id, 'locale' );
if ( $language && $language !== pll_current_language( 'locale' ) ) {
return false;
}
}
return $post_id;
@generatepress
generatepress / searchform.php
Created Mar 19, 2019
Fixed searchform.php. To be fixed in GP 2.3
View searchform.php
<?php
/**
* The template for displaying search forms in Generate
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@generatepress
generatepress / attachment.php
Created Mar 16, 2019
Example of attachment.php
View attachment.php
<?php
/**
* The Template for displaying all single posts.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@generatepress
generatepress / gist:9fe556128433b11114b489406fc8dee4
Created Feb 14, 2019
Disable the Header Element if there isn't a featured image.
View gist:9fe556128433b11114b489406fc8dee4
add_filter( 'generate_header_element_display', function( $display ) {
if ( ! has_post_thumbnail() ) {
return false;
}
return $display;
} );
@generatepress
generatepress / gist:18a46cb723eb8f1bb198d620b8d36814
Created Feb 13, 2019
Choose which post types you're entry meta displays on. Wrapped in after_setup_theme to fire later.
View gist:18a46cb723eb8f1bb198d620b8d36814
add_action( 'after_setup_theme', function() {
add_filter( 'generate_entry_meta_post_types', function( $types ) {
$types[] = 'my-post-type';
$types[] = 'recipes';
return $types;
} );
} );
@generatepress
generatepress / gist:a5f0dfd0db3c1d7fc5b217e07203fc58
Last active Nov 5, 2018
Remove screen reader text from more link in the feed
View gist:a5f0dfd0db3c1d7fc5b217e07203fc58
add_filter( 'generate_excerpt_more_output', function( $more ) {
if ( is_feed() ) {
return sprintf( ' ... <a title="%1$s" class="read-more" href="%2$s">%3$s</a>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) ),
__( 'Read more', 'generatepress' )
);
}
return $more;
@generatepress
generatepress / smooth-scroll.min.js
Created Oct 19, 2018
Potential fix for smooth scroll on mobile
View smooth-scroll.min.js
window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,n=(this.document||this.ownerDocument).querySelectorAll(e),o=this;do{for(t=n.length;0<=--t&&n.item(t)!==o;);}while(t<0&&(o=o.parentElement));return o}),function(){if("function"==typeof window.CustomEvent)return;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),function(){for(var a=0,e=["ms","moz","webkit","o"],t=0;t<e.length&&!window.requestAnimationFrame;++t)window.requestAnimationFrame=window[e[t]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[t]+"CancelAnimationFrame"]||window[e[t]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e,t){var n=(new Date).getTime(),o=Math.max(0,16-(n-a)),i=window.setTimeout(function(){e(n+o)},o);return a=n+o,i}),window.cancelAnimationFrame||(window.cance
@generatepress
generatepress / comments.php
Last active Oct 3, 2018
Move the comment form above the comments.
View comments.php
<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to generate_comment() which is
* located in the inc/template-tags.php file.
*
* @package GeneratePress
You can’t perform that action at this time.