Skip to content

Instantly share code, notes, and snippets.

Avatar

Victor M. Font Jr. vfontjr

View GitHub Profile
@vfontjr
vfontjr / filter_post_format.php
Last active Dec 14, 2018
Filter wp_query by post format
View filter_post_format.php
<?php
function filter_video_format_posts($query) {
/* change 999 to the page id for your archive page */
if ( !is_page ('999') )
return $query;
$taxquery = array(
array(
'taxonomy' => 'post_format',
@vfontjr
vfontjr / link-entry-content.php
Last active Dec 14, 2018
Wrap entry-content in link
View link-entry-content.php
<?php
add_action( 'genesis_before_entry_content', 'vmf_before_entry_content', 5 );
function vmf_before_entry_content() {
$permalink = get_permalink();
echo '<a href="' . esc_url( $permalink ) . '" >';
}
add_action( 'genesis_after_entry_content', 'vmf_after_entry_content' );
function vmf_after_entry_content() {
@vfontjr
vfontjr / fixed-header-offset.js
Last active Dec 14, 2018
Genesis anchor scroll fixed-header offset
View fixed-header-offset.js
(function( $ ) {
// Make sure JS is enabled.
document.documentElement.className = 'js';
$(document).ready(function() {
$( 'a[href*=#]:not([href=#])' ).click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
View Add same class to author link and category.php
@vfontjr
vfontjr / genesis-move-comments.php
Last active Dec 14, 2018
Move Comments Below Comment Form in Genesis
View genesis-move-comments.php
<?php
add_action( 'genesis_before_comments' , 'move_comments_below_form' );
function move_comments_below_form()
{
if ( is_single() && have_comments() ) {
remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
add_action( 'genesis_comments', 'genesis_do_comment_form', 5 );
}
@vfontjr
vfontjr / remove_type.php
Last active Dec 14, 2018
Remove "type" from script/style Tags
View remove_type.php
<?php
add_filter('style_loader_tag', 'codeless_remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'codeless_remove_type_attr', 10, 2);
function codeless_remove_type_attr($tag, $handle) {
return preg_replace('/ type=[\'"]text\/(javascript|css)[\'"]/', '', $tag );
}
@vfontjr
vfontjr / Genesis-Category-Outro-Text.php
Last active Dec 14, 2018
Add Outro text to category pages in Genesis
View Genesis-Category-Outro-Text.php
<?php
add_action( "genesis_after_loop", "display_category_outro");
function display_category_outro() {
if ( is_category() ) {
echo "test message for outro";
}
}
@vfontjr
vfontjr / alignfull-alignwide.css
Last active Mar 16, 2019
Adustments to Genesis CSS for Gutenberg
View alignfull-alignwide.css
.entry-content .alignfull,
.entry-content .alignwide {
margin-left : calc( -100vw / 2 + 100% / 2 );
margin-right : calc( -100vw / 2 + 100% / 2 );
max-width : 100vw;
}
@vfontjr
vfontjr / retrieve_post_id.php
Last active Dec 14, 2018
Formidable Pro: Retrieve Post ID and add to meta data
View retrieve_post_id.php
<?php
add_action('frm_after_create_entry', 'after_entry_created', 30, 2);
function after_entry_created($entry_id, $form_id) {
global $wpdb;
if ( $form_id == 2 ) {
$table_name = $wpdb->prefix . 'frm_items';
$post_id = $wpdb->get_var( "SELECT post_id FROM " . $table_name . " where id = " . $entry_id );
FrmEntryMeta::add_entry_meta( $entry_id, 131, "", $post_id); //change 131 to the ID of the field in which you want to store the entry ID
}
View debug_pending_updates.php
<?php
/* To see this output, add ?debug_updates to the site url and refresh the page */
function debug_pending_updates() {
// Rough safety nets
if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) return;
if ( ! isset( $_GET['debug_updates'] ) ) return;
$output = "";