We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
is there any function getting all post meta, as I using find($id) this is given me single post based on id. please help me for this
Thanks Rihan
The text was updated successfully, but these errors were encountered:
There are 2 way to retrieve the desired meta.
1) By accessing the meta array property
// Access a specific key $post->meta['key']; // PRINT ALL META print_t($post->meta);
2) By defining aliases
If you have a meta key called, for example, post_count (this is the exact name of the key in postmeta table).
post_count
postmeta
The you can define the alias for it in your model like:
class Post extends Model { protected $aliases = [ 'count' => 'meta_post_count' ]; }
And later use it like:
$post->count;
NOTE: Wordpress protected meta with prefix _wp_ need to be defined as aliases or else they will not be loaded by model.
_wp_
Example:
class Post extends Model { protected $aliases = [ 'wp_value' => 'meta__wp_post_value' ]; }
NOTE: For scope and security, only meta defined as alias can be updated into the DB.
Sorry, something went wrong.
No branches or pull requests
Hello,
is there any function getting all post meta, as I using find($id) this is given me single post based on id. please help me for this
Thanks
Rihan
The text was updated successfully, but these errors were encountered: