Skip to content

Instantly share code, notes, and snippets.

View vfontjr's full-sized avatar

Victor M. Font Jr. vfontjr

View GitHub Profile
@vfontjr
vfontjr / filter_post_format.php
Last active December 14, 2018 09:22
Filter wp_query by post format
<?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 December 14, 2018 09:25
Wrap entry-content in link
<?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 December 14, 2018 09:27
Genesis anchor scroll fixed-header offset
(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) {
@vfontjr
vfontjr / genesis-move-comments.php
Last active December 14, 2018 09:26
Move Comments Below Comment Form in Genesis
<?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 December 14, 2018 09:26
Remove "type" from script/style Tags
<?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 December 14, 2018 09:25
Add Outro text to category pages in Genesis
<?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 March 16, 2019 16:26
Adustments to Genesis CSS for Gutenberg
.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 December 14, 2018 09:22
Formidable Pro: Retrieve Post ID and add to meta data
<?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
}
@vfontjr
vfontjr / debug_pending_updates.php
Created December 14, 2018 09:21
Debug Pending Updates
<?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 = "";