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
//Register Meta with Rest API | |
add_action( 'rest_api_init', 'prefix_register_custom_meta' ); | |
function prefix_register_custom_meta() { | |
register_rest_field( | |
'post', | |
'_prefix_url', | |
array( | |
'get_callback' => 'prefix_get_custom_meta', | |
'update_callback' => null, | |
'schema' => null, |
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
/** | |
* Retrieve custom meta for use in the REST API | |
* | |
* @param array $object Details of current post. | |
* @param string $field_name Name of field. | |
* @param WP_REST_Request $request Current request | |
* | |
* @return mixed | |
*/ | |
function prefix_get_custom_meta( $object, $field_name, $request ) { |
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 basic_wp_seo() { | |
global $page, $paged, $post; | |
$default_keywords = 'wordpress, plugins, themes, design, dev, development, security, htaccess, apache, php, sql, html, css, jquery, javascript, tutorials'; // customize | |
$output = ''; | |
// description | |
$seo_desc = get_post_meta($post->ID, 'mm_seo_desc', true); | |
$description = get_bloginfo('description', 'display'); | |
$pagedata = get_post($post->ID); |
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 | |
/** | |
* Limit previous/next post title character length and append a ellipsis if trunicated | |
*/ | |
$previous_post = get_adjacent_post( false, '', true ); | |
$next_post = get_adjacent_post( false, '', false ); | |
$previous_post_title= get_the_title($previous_post); | |
$next_post_title = get_the_title($next_post); | |
$max_length = 75; | |
$previous_post_length = strlen($previous_post_title); |
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
// 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' ); |