This file contains 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 | |
/** | |
* Tests if any of a post's assigned categories are descendants of target categories | |
* | |
* @param int|array $cats The target categories. Integer ID or array of integer IDs | |
* @param int|object $_post The post. Omit to test the current post in the Loop or main query | |
* @return bool True if at least 1 of the post's categories is a descendant of any of the target categories | |
* @see get_term_by() You can get a category by name or slug, then pass ID to this function | |
* @uses get_term_children() Passes $cats | |
* @uses in_category() Passes $_post (can be empty) |
This file contains 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 | |
/** | |
* This funcion comes from the source code of WP-API: | |
* https://github.com/WP-API/WP-API/blob/develop/lib/endpoints/class-wp-rest-posts-controller.php#L91 | |
* | |
* Get a collection of posts | |
* | |
* @param WP_REST_Request $request Full details about the request | |
* @return WP_Error|WP_REST_Response | |
*/ |
This file contains 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
<!-- ... --> | |
<p>{{data.pageTitle}}</p> | |
<ul> | |
<li ng-repeat="post in data.posts"> | |
<a href="blog/{{post.ID}}" ng-bind-html="post.title"></a> | |
<a href="blog/{{post.ID}}" ng-if="post.featured_image.attachment_meta.sizes.thumbnail.url"><img ng-src="{{post.featured_image.attachment_meta.sizes.thumbnail.url}}" alt="{{post.featured_image.title}}" /></a> | |
<div ng-bind-html="post.excerpt"></div> | |
</li> | |
</ul> |
This file contains 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 my_json_prepare_term( $data, $term, $context ) { | |
global $wp_query; | |
$route = $wp_query->query['json_route']; | |
if ( ! preg_match( '/(terms\/.+)/', $route) ) | |
return $data; | |
$args = array( |
This file contains 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 my_rest_prepare_post( $data, $post, $request ) { | |
$_data = $data->data; | |
$thumbnail_id = get_post_thumbnail_id( $post->ID ); | |
$thumbnail = wp_get_attachment_image_src( $thumbnail_id ); | |
$_data['featured_image_thumbnail_url'] = $thumbnail[0]; | |
$data->data = $_data; |
This file contains 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
<search-form></search-form> | |
<p>Categories:</p> | |
<ul> | |
<li ng-repeat="category in data.categories"> | |
<span ng-if="current_category_id && category.ID == current_category_id" ng-bind-html="category.name"></span> | |
<a ng-if="!current_category_id || category.ID != current_category_id" href="category/{{category.slug}}" ng-bind-html="category.name"></a> | |
</li> | |
</ul> | |
<!-- ... --> |
This file contains 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
<h1>Page Not Found</h1> | |
<p>Sorry, but nothing can be found at this location.</p> |
This file contains 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
<!-- ... --> | |
<p>{{pageTitle}}</p> | |
<ul> | |
<li ng-repeat="post in posts"> | |
<a href="blog/{{post.ID}}" ng-bind-html="post.title"></a> | |
<a href="blog/{{post.ID}}" ng-if="post.featured_image.attachment_meta.sizes.thumbnail.url"><img ng-src="{{post.featured_image.attachment_meta.sizes.thumbnail.url}}" alt="{{post.featured_image.title}}" /></a> | |
<div ng-bind-html="post.excerpt"></div> | |
</li> | |
</ul> | |
<posts-nav-link prev-label="« Previous Page" next-label="Next Page »"></posts-nav-link> |
This file contains 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 | |
$args = array( | |
'posts_per_page' => -1, | |
'meta_query' => array( | |
array( | |
'key' => 'foo', | |
'value' => 'bar' | |
) | |
), |
This file contains 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
<h1 ng-bind-html="post.title"></h1> | |
<slick dots="true" autoplay="true" slides-to-show="1" slides-to-scroll="1" init-onload="true" data="media" style="width:300px"> | |
<div ng-if="image.is_image" ng-repeat="image in media"> | |
<img alt="{{image.title}}" ng-src="{{image.attachment_meta.sizes.medium.url}}" /> | |
</div> | |
</slick> | |
<div ng-bind-html="post.content"></div> |