garyK-5
In den letzten 30 Tagen erstellte Support-Threads: 0
Lieblings-Forenthemen
This user has no favorite topics.
Forum Topics Created
| Status | Thema | Supporter | Stimmen | Artikel | Aktualität |
|---|---|---|---|---|---|
|
Adding a Numeric Monitary Value of a Filter
Gestartet von: garyK-5
in: Toolset Professional Support
Problem: How to filter the addition of numeric values in a search Solution: Make sure that you put the sum of the numeric values after the view. Sample code to get started on how to create a shortcode for that:
/**
* Register shortcode to add field values for each item in loop to give total (after loop)
*/
add_shortcode('sum-item', function ($atts=[],$content = null) {
$atts = shortcode_atts(
array(
'total' => null
),
$atts
);
static $running = 0;
$output = "";
if ( ! is_null( $content ) )
{
$content = do_shortcode( ltrim($content) );
if ( is_numeric( $content ) )
{
$running += $content;
}
}
if ( ! is_null( $atts['total'] ) )
{
$output = $running;
}
return $output;
});
How to use the shortcode:
/** An example of usage in the output of a View: */
[wpv-items-found]
[wpv-post-link]
[sum-item] [types field="number-field"][/types][/sum-item]
[sum-item total=true]
[/wpv-items-found]
|
|
2 | 7 | vor 4 years, 2 months | |
|
format as money calculated function on Views
Gestartet von: garyK-5
in: Toolset Professional Support
Problem: The issue here is that the user wanted to convert the output of they're code to currency format. Instead of the function returning 1000 they wanted $1,000.00 Solution: This can be done by wrapping your final output from your code with the number_format() function. Here is a quick sample below. $num = 1000; //value to be passed return "$".number_format($num, 2, '.', ','); // The above will change the format to $1,000.00 For more details on the number_format() function you can check the php documentation. |
|
2 | 8 | vor 4 years, 5 months | |
|
Content Template being used on all unique post types
Gestartet von: garyK-5 in: Toolset Professional Support |
|
2 | 5 | vor 4 years, 6 months | |
|
Styling Search and Reset Button
Gestartet von: garyK-5 in: Toolset Professional Support |
|
2 | 10 | vor 4 years, 9 months |