Skip to content

Instantly share code, notes, and snippets.

View leoken's full-sized avatar

Erik James Albaugh leoken

  • Maintain Web
  • Long Beach, CA
  • X @leoken
View GitHub Profile
@leoken
leoken / add-to-feed.php
Created October 19, 2013 06:39
Add a custom post type to the regular wp posts feed.
<?php
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( 'post_type', array( 'post', 'wprss_feed_item', ) );
return $query;
}
application: YOUR_PROJECT_IDversion: wpruntime: phpapi_version: 1handlers:- url: /(.*\.(htm$|html$|css$|js$))  static_files: wordpress/\1  upload: wordpress/(.*\.(htm$|html$|css$|js$))  application_readable: true- url: /wp-content/(.*\.(ico$|jpg$|png$|gif$))  static_files: wordpress/wp-content/\1  upload: wordpress/wp-content/(.*\.(ico$|jpg$|png$|gif$))  application_readable: true- url: /(.*\.(ico$|jpg$|png$|gif$))  static_files: wordpress/\1  upload: wordpress/(.*\.(ico$|jpg$|png$|gif$))- url: /wp-admin/(.+)  script: wordpress/wp-admin/\1  secure: always- url: /wp-admin/  script: wordpress/wp-admin/index.php  secure: always- url: /wp-login.php  script: wordpress/wp-login.php  secure: always- url: /wp-cron.php  script: wordpress/wp-cron.php  login: admin- url: /xmlrpc.php  script: wordpress/xmlrpc.php- url: /wp-(.+).php script: wordpress/wp-\1.php- url: /(.+)?/?  script: wordpress/index.php
<?php
/*
Plugin Name: Aggressivex Network Custom Post
Version: 1.0
Author: Luis Muñoz
Author URI: http://www.aggressivex.com/author/luis.munoz/
*/
class AN_custom_post
{
var $post_type_name = 'product';
<?php
/*
GeoRSS formatted output for Google Maps
Authors: Alastair Mucklow, Chris Toppon
*/
//header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
//$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'" standalone="yes"?'.'>'; ?>
<?php
$the_slug = 'my-slug';
$args=array(
'name' => $the_slug,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1
);
$my_posts = get_posts( $args );
if( $my_posts ) {
@leoken
leoken / show-attachments-minus-featured.php
Created October 14, 2013 13:59
Show all attachments for the current post except the Featured Image From http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id
<?php
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=catswhocode');
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
<?php
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if(is_plugin_active('plugin-directory/plugin-file.php')) {
//plugin is activated
}
?>