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:565683b10cca65050d7fb3a006efbc29
Created Jul 19, 2019
Add search button with icon to the navigation search
View gist:565683b10cca65050d7fb3a006efbc29
add_filter( 'generate_navigation_search_output', function() {
printf(
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
<input type="submit" class="search-button" value="&#xf002;">
</form>',
esc_url( home_url( '/' ) ),
esc_attr( get_search_query() ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
View gist:2bb2667c9413e29579288687add966de
add_filter( 'generate_typography_default_fonts', function( $fonts ) {
if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) {
return $fonts;
}
$all_fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
if ( ! empty( $all_fonts ) ) {
foreach ( $all_fonts as $font_family_name => $fonts_url ) {
$fonts[] = $font_family_name;
@generatepress
generatepress / comments.php
Created Jul 18, 2019
Move comment form above list of 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
@generatepress
generatepress / gist:64ee0304f3fd166f02df341fc9cc0968
Created Jul 2, 2019
Adding a search icon to the GP search form button
View gist:64ee0304f3fd166f02df341fc9cc0968
add_filter( 'generate_search_button', function() {
return '&#xf002;';
} );
@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;
} );
You can’t perform that action at this time.