Skip to content

Instantly share code, notes, and snippets.

View carlitoescobar's full-sized avatar
👁️
Looking

Carlito carlitoescobar

👁️
Looking
View GitHub Profile
<?php
/**
* Adding an ad after the second paragraph
*
*/
add_filter( 'the_content', 'tb_insert_post_ads' );
function tb_insert_post_ads( $content ) {
$ad_code = 'The ad code goes here. Both static ads and Google Adsense.';
<?php
// Copy from here
//Deleting WordPress authentification
remove_filter('authenticate', 'wp_authenticate_username_password', 20);
// Placing new authentification - sign up via email and password only
add_filter('authenticate', function($user, $email, $password){
//Check for empty fields
<?php
/**
* A new logo for the admin area and an own background color
* @author Andreas Hecht
*/
function ah_login_logo() {
?>
<style type="text/css">
#login h1 a, .login h1 a {
@carlitoescobar
carlitoescobar / filter_taxonomy_existing_loop.php
Last active September 30, 2015 14:32
Only return taxonomies that exist in current loop. Using it on another taxonomy terms archive page.
<?php
while (have_posts()) : the_post();
$taxonomy = 'your_taxonomy'; // change this to your taxonomy
//$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) );
$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "slugs" ) );
if( $terms ) $all_terms = array_merge($all_terms, $terms);
endwhile;
if ($all_terms) :
@carlitoescobar
carlitoescobar / gravityforms-checkbox-checkall.js
Created February 7, 2015 00:00
Gravity Forms check all function (jQuery)
// Needed this for a client project, thanks! I improved upon it to make it more generic so you don't have to look up individual IDs on elements:
jQuery(document).ready(function(){
// Check all in Gravity Forms
jQuery('.checkall li:first-child input').click(function() {
jQuery(this).parent('li').parent('ul').find(':checkbox').attr('checked', this.checked);
});
});
// Just add a class "checkall" to your checkbox form item in Gravity Forms, it assumes the first item in the list will be the "All" option.
<?php // custom functions.php template @ digwp.com
// add feed links to header
if (function_exists('automatic_feed_links')) {
automatic_feed_links();
} else {
return;
}