POSTS:
Get a post by id:
http://mixmeals.com/wp-json/wp/v2/posts/?filter[p]=12
Get multiple posts by id:
http://mixmeals.com/wp-json/wp/v2/posts/?include=470,469
| <?php | |
| function get_field_choices($field_key) { | |
| $field = get_field_object($field_key); | |
| if( $field ) | |
| { | |
| $results = array(); | |
| foreach( $field['choices'] as $k => $v ) | |
| { |
| function responsive_image_background($image_field_name) { | |
| $imageobject = get_field($image_field_name); | |
| echo '<img class="fullscreen__image-background" src="' . $imageobject['sizes']['superhero'] . '" srcset="' . $imageobject['sizes']['superhero'] .' '. $imageobject['sizes']['superhero-width'] .'w, ' . $imageobject['sizes']['hero'] .' '. $imageobject['sizes']['hero-width'] .'w, '. $imageobject['sizes']['large'] .' '. $imageobject['sizes']['large-width'] .'w">'; | |
| } |
| <img src="image-src.png" srcset="image-1920x960.png 1920w, image-1280x680.png 1280w, image-600x320.png 600w"> |
| // React Router V4 | |
| // Pass props to a component being matched | |
| <Match pattern='/create' exactly render={() => ( | |
| <Create | |
| dbItems={this.dbItems} | |
| /> | |
| )} /> | |
POSTS:
Get a post by id:
http://mixmeals.com/wp-json/wp/v2/posts/?filter[p]=12
Get multiple posts by id:
http://mixmeals.com/wp-json/wp/v2/posts/?include=470,469
| import React, { Component } from 'react' | |
| import { Redirect } from 'react-router' | |
| export default class ContactForm extends Component { | |
| constructor () { | |
| super(); | |
| this.state = { | |
| fireRedirect: false | |
| } | |
| } |
| // Forked createCss method from markerclusterer | |
| // Sets icon background size to same size as icon width and height | |
| // Add this file after loading markerclusterer.js https://github.com/googlemaps/js-marker-clusterer | |
| ClusterIcon.prototype.createCss = function(pos) { | |
| var style = []; | |
| style.push('background-image:url(' + this.url_ + ');'); | |
| var backgroundPosition = this.backgroundPosition_ ? this.backgroundPosition_ : '0 0'; | |
| style.push('background-position:' + backgroundPosition + ';'); | |
| style.push('background-size: ' + this.width_ + 'px ' + this.height_ + 'px;'); //added to support retina |
| <FilesMatch ".(eot|ttf|otf|woff)"> | |
| Header set Access-Control-Allow-Origin "*" | |
| </FilesMatch> | |
| Header add Access-Control-Allow-Origin "your-domain.com" | |
| ## To test access-control-allow-headers in terminal: | |
| ## curl -I https://some.cdn.otherdomain.net/media/fonts/somefont.ttf | |
| const myobject = {} | |
| myobject[ key ] = value | |
| // { key: value } | |
| // Add element to array | |
| const myarray = [] | |
| myarray.push(value1) | |
| myarray.push(value2) | |
| // [value1,value2] |
| // Including twig files with vars | |
| {% include "button.twig" with { text: "Click me" } %} | |
| // Debug (enable WP debugging) | |
| {{post|print_r}}// deprecated | |
| {{dump(post)}} | |
| // Image URL with custom image size | |
| {{ TimberImage( fieldname ).src('large') }} |