This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_taxonomies_terms_links() { | |
global $post, $post_id; | |
// get post by post id | |
$post = &get_post($post->ID); | |
// get post type by post | |
$post_type = $post->post_type; | |
// get post type taxonomies | |
$taxonomies = get_object_taxonomies($post_type); | |
$out = "<ul>"; | |
foreach ($taxonomies as $taxonomy) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress Query Comprehensive Reference | |
* Compiled by luetkemj - luetkemj.com | |
* | |
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters | |
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php | |
*/ | |
$args = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use the built-in post counter | |
* | |
* Sometimes you'll want to keep track of which post you're on in a loop. | |
* Some people create their own $loop_counter (ex: Genesis, https://gist.github.com/4675237 ). | |
* There's a better way! A loop counter is built into $wp_query. Ex: | |
* | |
* global $wp_query; | |
* echo $wp_query->current_post |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** A simple text block **/ | |
if(!class_exists('AQ_Portfolio_Block')) { | |
class AQ_Portfolio_Block extends AQ_Block { | |
//set and create block | |
function __construct() { | |
$block_options = array( | |
'name' => 'Portfolio', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Easy! Using the example of a custom post type called ‘the_event’, | |
* you’d just put the following into your functions.php file (or plugin). | |
* Credits go to author: https://bay-a.co.uk/wordpress-tips/wp-api-v2-tips/ | |
*/ | |
add_action( 'init', 'add_events_to_json_api', 30 ); | |
function add_events_to_json_api(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit goes to authors of answers here: http://stackoverflow.com/a/2865393/1152876 | |
<?php | |
/* | |
* Example array, the values are grabbed from a custom field on WordPress. | |
* Works well if you need a solution that can accept any array. | |
*/ | |
$array = get_post_meta( get_the_ID(), '_prefix_my_custom_field', true ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Receive one array as input, filter values from it, and output as another array. | |
// The function should loop through up to x iterations. | |
// Credits go to the author of the answer here: http://stackoverflow.com/a/7274450/1152876 | |
*/ | |
* Exit the foreach loop when count is reached. | |
* Use a foreach to iterate over the full array, and if the stated maximum count isn't reached, process the whole array. | |
* Otherwise, if the maximum iteration is reached, jump out of the loop. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add custom post types main RSS feed. | |
function wp_rss_feed( $query ) { | |
if ( $query->is_feed() ) | |
$query->set( 'post_type', array( 'post', 'events', 'books' ) ); | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'wp_rss_feed' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function artigo_feed_rewrite( $wp_rewrite ) { | |
$feed_rules = array( | |
'feed/artigos' => 'index.php?post_type=listing&feed=rss2' | |
); | |
$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; | |
} | |
// regerar regras de permalinks depois de ativar / implementar esse código |