Skip to content

Instantly share code, notes, and snippets.

@anthonybudd
Created February 6, 2017 16:54
Show Gist options
  • Select an option

  • Save anthonybudd/cee9c377d9b48a01ea325b1ef751cea9 to your computer and use it in GitHub Desktop.

Select an option

Save anthonybudd/cee9c377d9b48a01ea325b1ef751cea9 to your computer and use it in GitHub Desktop.
<?php
Product::single(); // Returns the current model if on a single page or in the loop
Product::exists(15); // Returns (bool) true or false
$product->post() // Returns WP_Post object
$product->permalink() // Returns post permalink
$product->featuredImage($defaultURL) // Returns featured image URL
$product->toArray() // Returns an array representation of the model
Product::asList() // Returns array of posts keyed by the post's ID
[
15 => Product,
16 => Product,
17 => Product
]
// You can also specify the value of each element in the array to be meta from the model.
Product::asList('post_title')
[
15 => "Product 1",
16 => "Product 2",
17 => "Product 3"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment