The function should be able to convert as many object/data types to a Rila object as possible. It should receive a single argument, which works similarly to the second argument for ACF's get_field function.
Possible types
Type
Example value
Target
int
3
Rila\Post
WP_Post
get_post( 3 )
Rila\Post
WP_Term
get_term_by( 'id', 5, 'category' )
Rila\Term
WP_User
get_user_by( 'email', 'user@example.com' )
Rila\User
WP_Comment
get_comment( 5 )
Rila\Comment
string
'post_3'
Rila\Post
string
'term_3'
Rila\Term
Examples
<?php
# Just get a post by ID
$post = rila( 3 );
# Get a post by using a WP object
$post = get_post( 3 );
$post = rila( $post );
# Get a post by a (post type) string
$post = rila( 'event_10' );
# Get a term by a (custom taxonomy) string
$term = rila( 'category_3' );
Extension
It would be cool if the function allowed custom "data" types to be used. If the framework has a "Tweet" class, which handles a tweet, it would be cool to be able to get the tweet by ID:
<?php
$tweet = new rila( 'tweet_234364323' );
Arrays
Eventually, the function would also support arrays of values and create the respective collection.
No parameter
If there is no parameter, the function could simply create a collection of posts and allow further augumentation, in order to imitate jQuery:
The function should be able to convert as many object/data types to a Rila object as possible. It should receive a single argument, which works similarly to the second argument for ACF's get_field function.
Possible types
Examples
Extension
It would be cool if the function allowed custom "data" types to be used. If the framework has a "Tweet" class, which handles a tweet, it would be cool to be able to get the tweet by ID:
Arrays
Eventually, the function would also support arrays of values and create the respective collection.
No parameter
If there is no parameter, the function could simply create a collection of posts and allow further augumentation, in order to imitate jQuery: