Jeshua
Forum Replies Created
-
It works!. Obviusly… honestly I don’t know how I passed that. Hahaha Thanks Scott!!.
Thanks for your answed Scott. But didn’t work in the query. My changed code:
function query_manuales ( $query, $widget ) { $formacion_assets = pods( 'formacion', get_the_id() ); $argu = array( 'name' => 'assets_activos', 'output' => 'ids', ); $insertar_assets = $formacion_assets->field( $argu ); $query->set( 'post_type', ['formacion'] ); $query->set('post__in', [ $insertar_assets ] ); } add_action( 'elementor/query/assets_query', 'query_manuales', 10, 2 );
I example, if I change
$insertar_assets
in$query->set('post__in', [ $insertar_assets ] );
by$query->set('post__in', [ 1234 , 5678 , 9123] );
In the place where I want to use the query it works. That show three posts, that is the same thing that I’m wondering with the field (assets_activos) in my pod (formacion).I need that format for the value because I need to insert it in a query:
function query_manuales ( $query, $widget ) { $formacion_assets = pods( 'formacion', get_the_id() ); $insertar_assets = $formacion_assets->display( 'assets_activos' ); $query->set( 'post_type', ['formacion'] ); $query->set('post__in', [ $insertar_assets ] ); } add_action( 'elementor/query/assets_query', 'query_manuales', 10, 2 );
So the
post__in
method needs an array of post id’s.Thanks for your help of beforehand. If I’m missing something, please I’ll be glad if you let me know.
Forum: Plugins
In reply to: [Pods - Custom Content Types and Fields] Math with custom fields.Thanks!! It works, I was missing the dynamic id to call the custom field for the individual posts of the cpt.
My final function was this:
function fields_multiply () { //START FUNCTION //GET THE MANUAL RATE $rate = pods( 'rate', 'manualrate')->find( $params ); $therate = $rate->field( 'therate' ); //FIND CURRENCIES $currency = pods( 'currency', get_the_id() /* THIS IS WHAT I WAS MISSING */ ); $price = $currency->field( 'price' ); //MULTIPLY AND RESULT $totalprice = $therate * $price; echo '<p>' . $totalprice . '</p>'; } //END FUNCTION // CREATE SHORTCODE add_shortcode( 'fields_total', 'fields_multiply' );
If I was missing something more, please, I’ll be grateful if you tell me.
Forum: Plugins
In reply to: [Pods - Custom Content Types and Fields] Math with custom fields.Ok… I’ll try it.
- This reply was modified 5 years, 9 months ago by Jeshua.
Forum: Plugins
In reply to: [Pods - Custom Content Types and Fields] Math with custom fields.I’ve created an initial function and shortcode to only show the value of the “value” field of the “currency” cpt and then use it in the page builder or any place:
function fields_multiply() { $currency = pods( 'currency' ); $value = $currency->display('value'); echo $value; } add_shortcode( 'fields_total', 'fields_multiply' );
This is only for test purposes, but didn’t work. The rest is create de variables to create another that shows the result of the multiplication of the “actualrate” field from the “rate” cpt of a certain post of that cpt and “value” field of the “currency” cpt (this is for individual posts that will be created for that cpt).
The code is inside a custom pods-starter plugin that I found googling. The shortcode woks becuase if I change i.e.:
echo 'ANYTHING HERE';
rather than the code above inside the function, the echo shows that result anywhere I want with the shortcode “fields_total”.