htmlBurger
Forum Replies Created
-
Forum: Plugins
In reply to: [Carbon Fields] query posts based on carbon fields valueGreat! Good luck with your project. 🙂
Forum: Plugins
In reply to: [Carbon Fields] query posts based on carbon fields valueI suggest that you wrap the href attribute value in a pair of
". So instead ofhref=<?php echo $doclink; ?>you would havehref="<?php echo $doclink; ?>".Other than that, the code appears to be fine (considering that we don’t have your full code and we’re blindly debugging).
So it appears you don’t have a file uploaded to that document. In that case the link will be empty, resulting in a link to the current post (which is probably a project in your case).
Forum: Plugins
In reply to: [Carbon Fields] query posts based on carbon fields valueHowdy, @tomwhita,
It appears your meta_query should be like this:
$args = array( 'post_type' => array( 'document' ), 'post_status' => array( 'publish' ), 'meta_query' => array( array( 'key' => '_doc_project_association', 'compare' => 'LIKE', 'value' => '"post:project:' . $post->ID . '"', ) ) );I’ve changed several things:
1. The post type is now
document– previously it waspost. This was necessary as I can see your container is registered on thedocumentpost type and not onpost.
2. I’ve added'compare' => 'LIKE'– this is necessary in order to make a full text search within the serialized value.
3. Thevaluehas been changed to'"post:project:' . $post->ID . '"'– this is how the association field values are saved in the database.Please, let me know if you have further questions.
Forum: Plugins
In reply to: [Carbon Fields] query posts based on carbon fields valueHey @tomwhita,
Can you please send the definition of
_doc_project_associationfield? We need the code that creates the field, so we know how the value is stored in the database.Forum: Plugins
In reply to: [Carbon Fields] Retrieving values using get_post_metaHi @tomwhita,
It appears you’ve missed it – it exists in the documentation. Basically there is a different data retrieval function for each container type – it can be found under the “Accessing field values” section in the documentation article of the corresponding container.
For example, you will easily notice it in the Post Meta container article in the documentation: http://carbonfields.net/docs/containers-post-meta/
Forum: Plugins
In reply to: [Carbon Fields] Retrieving values using get_post_metaHi @tomwhita,
You haven’t posted the definition of your fields, but it appears you’re missing an underscore at the beginning of the field. Let us explain.
You have generally 2 ways of retrieving a post meta field:
1. Using
get_post_meta()
2. Using the Carbon Fields functioncarbon_get_post_meta().We recommend using the second one. Your code would then be:
<time>Start Date: <?php echo carbon_get_post_meta($post->ID, 'project_start_date'); ?></time>and in case you still want to use
get_post_meta(), you will have to prefix the field with an underscore, like this:<time>Start Date: <?php echo get_post_meta($post->ID, '_project_start_date', true); ?></time>You might be wondering why the underscore prefix? Well, you’ve probably seen the default Custom Fields interface in WordPress? If you don’t prefix your post meta fields with an underscore, they will be shown in that interface as well. That is why most custom fields plugins add that prefix to their fields. And WordPress core also does that for internal post meta (like
_thumbnail_idthat is used for the post featured image).Please, don’t hesitate to let us know if you have any other questions.
Forum: Plugins
In reply to: [Carbon Fields] dimension of images category with carbon fieldsHi Dewy,
It appears you’re on the right track. You only have to use some WP default functions to achieve what you want.
We suggest that you proceed the following way:
1. First, make sure that you’re using the latest Carbon Fields (1.1). This will assure that you rimage field is saving the attachment ID (and not the URL).
2. Once this is true,$image = carbon_get_term_meta($term->term_id, 'crb_thumb')will return a numeric ID of the attachment.
3. You can use this ID to display an image with your preferred size, like this:echo wp_get_attachment_image( $image, array( 450, 450 ) )or if you have a predefined image size (registered with
add_image_size()):echo wp_get_attachment_image( $image, 'image_size_name' )If you want to combine this into one line, it would be:
echo wp_get_attachment_image( carbon_get_term_meta( $term->term_id, 'crb_thumb' ), array( 450, 450 ) )And if you want to receive the image details (width, height, URL, etc.), you can use:
$image = wp_get_attachment_image_src( carbon_get_term_meta( $term->term_id, 'crb_thumb' ), array( 450, 450 ) )and then
$imagewill contain an array with the image details (as shown here: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/).Please, let us know if you have further questions.
Have fun! 🙂
Forum: Plugins
In reply to: [Carbon Fields] How to embed/include Carbon Fields in a themeHi Mayeenul,
We apologize we could not reply sooner.
Also, we’re constantly working on improving the documentation, and we’ll soon introduce some more articles and guides that will be helpful when you use Carbon Fields for the first time.
And we hope Carbon Fields will be the right library for you next time.
Good luck with your project! 🙂
Forum: Plugins
In reply to: [Carbon Fields] How to embed/include Carbon Fields in a themeHi Mayeenul!
The best way to use the Carbon Fields in the theme is to load it with Composer – https://getcomposer.org. To do that, you should add
htmlburger/carbon-fieldsas a composer dependency (in thecomposer.jsonfile), then load Composer’s autoload file (for example in your themefunctions.php).If you’re having difficulties with that approach, you should try including the Carbon Fields plugin file in your theme
functions.php– it will setup the autoloading for you. Example:require(__DIR__ . '/libs/carbon-fields/carbon-fields-plugin.php');Please, let us know if you’re having further issues.
Forum: Plugins
In reply to: [Carbon Fields] Limit characters on text field inputThe new location of the Extending docs article is here: http://carbonfields.net/docs/advanced-topics-extending/
Forum: Plugins
In reply to: [Carbon Fields] complex field in a static pageHey @stardeuche,
As far as I understand, you were able to find your way?
Please, don’t hesitate to let us know if you have any further questions.
Forum: Plugins
In reply to: [Carbon Fields] Nested Complex Fields PHP output sample code?Hi Richard,
Thanks for the translation! We really appreciate it.
We’re developing the plugin in GitHub (and store the translations there as well). Do you want to add your translation file there? In case you do, you should follow the steps that we’ve outlined in the following GitHub issue https://github.com/htmlburger/carbon-fields/issues/2
Thank you!
Forum: Plugins
In reply to: [Carbon Fields] Nested Complex Fields PHP output sample code?Hey Richard,
Glad we were able to help.
We currently don’t have Dutch translation, so it would be really wonderful if you can contribute with it.
Forum: Plugins
In reply to: [Carbon Fields] Nested Complex Fields PHP output sample code?Hey there,
We’ve prepared a quick example on how to output the sections, rows and columns based on the markup that you provided, considering the nested complex fields that you’ve registered above.
You can find it here: https://gist.github.com/tyxla/7c9c7691e6101375ea07
Feel free to experiment with it.
Cheers
Forum: Plugins
In reply to: [Carbon Fields] Limit characters on text field inputHi @yoderman94,
Within the current version there isn’t an out-of-the-box way to do it. It is a planned feature for one of the next versions.
If you need to implement it right now, you can create a custom Carbon Field type, by extending the Text or Textarea field. There you can add the custom functionality you need.
There is a custom field type template that you can use for starting. You can read more about it here: http://carbonfields.net/docs/extending/