Skip to content

Instantly share code, notes, and snippets.

View madeinnordeste's full-sized avatar
:octocat:
Coding

Luiz Alberto S. Ribeiro madeinnordeste

:octocat:
Coding
View GitHub Profile
@madeinnordeste
madeinnordeste / wp-strore-query-for-reuse.php
Last active August 29, 2015 14:00
Wordpress : Strore Query for reuse
<!-- saving the query -->
<?php $temp_query = clone $wp_query; ?>
<!-- listing out featured articles -->
<?php query_posts('category_name=featured&showposts=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Do special_cat stuff... -->
<?php endwhile; ?>
@madeinnordeste
madeinnordeste / wp-show-post-page-parent-title.php
Last active August 29, 2015 14:01
Wordpress - Show post/page parent title
<?php
if($post->post_parent) {
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
} else {
wp_title('');
}
?>
@madeinnordeste
madeinnordeste / wp-custom-post-type.php
Last active February 22, 2017 19:33
Wordpress - Custom post type
<?php
//in theme functions.php
// @see http://codex.wordpress.org/Function_Reference/register_post_type
$labels = array(
'name' => _x('Edição Digital', 'Edição Digital'),
'singular_name' => _x('edicao_digital', 'Edição Digital'),
'add_new' => _x('Nova Edição Digital', 'edicao_digital'),
'add_new_item' => __('Adicionar nova Edição Digital'),
@madeinnordeste
madeinnordeste / sendy-global-bounce-subscriber.php
Last active November 30, 2016 04:51
Sendy - Global bounce email - http://YOU-SEND-INSTALL/api/subscribers/global-bounce-subscriber.php
<?php include('../_connect.php');?>
<?php include('../../includes/helpers/short.php');?>
<?php
//-------------------------- ERRORS -------------------------//
$error_core = array('No data passed', 'API key not passed', 'Invalid API key');
$error_passed = array('Email not passed', 'List ID not passed', 'Email does not exist in list');
//-----------------------------------------------------------//
//--------------------------- POST --------------------------//
//api_key
@madeinnordeste
madeinnordeste / skype-link-to-call.html
Created March 1, 2015 15:11
Skype: Link to call user
@madeinnordeste
madeinnordeste / wp-admin-disable-tinymce_buttons.php
Created March 1, 2015 15:16
Wordpress: Admin disable TinyMCE buttons
<?php
/*
Disable tinyMCE buttons in Wordpress admin
add lines in 'wp-content/themes/<youttheme>/functions.php'
*/
function do_change_mce_buttons( $initArray ) {
//@see http://wiki.moxiecode.com/index.php/TinyMCE:Control_reference
@madeinnordeste
madeinnordeste / wp-automatic_show_author_bio_each_post.php
Last active August 29, 2015 14:16
Wordpress: Automatic show author bio each post
<?php
function get_author_bio ($content=''){
global $post;
$post_author_name=get_the_author_meta("display_name");
$post_author_description=get_the_author_meta("description");
$html="<div class='clearfix' id='about_author'>\n";
$html.="<img width='80' height='80' class='avatar' src='http://www.gravatar.com/avatar.php?gravatar_id=".md5(get_the_author_email()). "&default=".urlencode($GLOBALS['defaultgravatar'])."&size=80&r=PG' alt='PG'/>\n";
$html.="<div class='author_text'>\n";
@madeinnordeste
madeinnordeste / wp-fetch_and_display_rss_feeds.php
Last active August 29, 2015 14:16
Wordpress: Fetch and display RSS feeds
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH.WPINC.'/feed.php');
$feed = fetch_feed('http://feeds.feedburner.com/catswhoblog');
$limit = $feed->get_item_quantity(7); // specify number of items
$items = $feed->get_items(0, $limit); // create an array of items
}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
@madeinnordeste
madeinnordeste / wp-fetch_rss_feed.php
Created March 1, 2015 15:18
Wordpress: Fetch RSS feed
<?php
//see: http://codex.wordpress.org/Function_Reference/fetch_feed
//see: http://simplepie.org/wiki/reference/start#simplepie_item
?>
<h2><?php _e('Recent news from Some-Other Blog:'); ?></h2>
<?php // Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/feed.php');
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('http://feeds.feedburner.com/euqueroserummacaco/madeinnordeste');
@madeinnordeste
madeinnordeste / wp-get-recent-comments.php
Created March 1, 2015 15:19
Wordpress: Get recent comments
<?php
function get_recent_comments($total=3, $excerpt_length=100){
$pre_HTML ="";
$post_HTML ="";
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,".$excerpt_length.") AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT ".$total;