Skip to content

Instantly share code, notes, and snippets.

<?php
$args = array(
'post_type' => 'services'
);
$the_query = new WP_query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post() ;?>
@ericjuden
ericjuden / gridview_with_rank.aspx.cs
Last active December 11, 2015 20:29
ASP.NET/C# GridView Rank column
public partial class Leaders : System.Web.UI.Page {
private int rank = 0; // Rank of the current record in GridView
private int currentPage = 0; // tracks current page in GridView
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
// Find label control to update
Label lblRank = (Label)e.Row.FindControl("lblRank");
// On page reload, rank is reset to 0
if (rank == 0) {
@ericjuden
ericjuden / speak-pirate.php
Created January 28, 2013 14:34
Speak Pirate plugin for WordPress
<?php
/**
* Plugin Name: Speak Pirate
* Plugin URI:
* Description: translates text in a shortcode into the equivalent text spoken as a pirate
* Author: ericjuden
* Author URI: http://ericjuden.com
* Version: 1.0
*/
@ericjuden
ericjuden / my-object-oriented-plugin.php
Created January 28, 2013 14:40
Object-Oriented Plugin for WordPress boilerplate
<?php
/**
* Plugin Name: My Object-Oriented Plugin
* Plugin URI: Plugin Website Here
* Description: Your Description Here
* Author: Your Name Here
* Author URI: Your Website Here
* Version: 1.0
*/
@ericjuden
ericjuden / edit-author-name.php
Created January 28, 2013 14:52
Edit Post Author Name in WordPress Feeds
<?php
function my_rss2_ns(){
global $in_rss_feed;
$in_rss_feed = true;
}
add_action('rss2_ns', 'my_rss2_ns');
function my_the_author($author){
global $in_rss_feed;
@ericjuden
ericjuden / wordpress-options.php
Created February 8, 2013 15:49
WordPress Options Class
<?php
class My_Plugin_Options {
var $options;
var $option_name;
var $is_site_option; // Are we using Multisite and saving to global options?
function My_Plugin_Options($option_name, $is_site_options = false){
$this->option_name = $option_name;
$this->is_site_option = $is_site_options;
if($this->is_site_option){
@ericjuden
ericjuden / prepare-sql.php
Last active December 12, 2015 09:58
WordPress St. Louis Developers Meetup: Security Best Practices
<?php
global $wpdb;
// Clean SQL before running
$sql = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE status = %s AND post_type = %s', 'publish', 'page');
// Return results
$results = $wpdb->get_results($sql);
?>
@ericjuden
ericjuden / create-sample-tables.php
Last active December 14, 2015 19:29
WordPress Custom Tables
<?php
/*
Plugin Name: Create Sample Tables Plugin
Plugin URI: http://ericjuden.com
Description: Create some dummy tables
Version: 1.0
Author: ericjuden
Author URI: http://ericjuden.com
*/
@ericjuden
ericjuden / default-sections.css
Last active December 16, 2015 15:09
Default Starter Stylesheet
/********************************************************
* Main Body Styles
********************************************************/
/********************************************************
* Header Styles
********************************************************/
@ericjuden
ericjuden / list-blogs.php
Created May 15, 2013 11:55
WordPress Multisite: List Blogs
<?php if(is_front_page()){ ?>
<h1>Blog Directory</h1>
<?php
global $wpdb;
$query = "SELECT blog_id FROM " . $wpdb->base_prefix . "blogs WHERE spam != '1' AND archived != '1' AND deleted != '1' AND public = '1' AND blog_id != '1' ORDER BY path";
$blogs = $wpdb->get_results($query);
echo '<ul>';