Thanks
DV
I’ve a code snippet format custom post rating number.
It works fine on a page where post are in grids.
You can see in: Economia – WeYourConsult
But when I open the post the number is show as:
Rating: [format-currency num=”1.020” sym=””]
La Contabilità in breve – WeYourConsult
If I disable FreeSoul it works fine, and also if I activate all plugins for pages or CPT, results doesn’t change.
In order to call the function I use Avada subtitle layout: https://avada.com/documentation/category/layouts/
With Avada builder I insert a Text block like:
{!{wpv-conditional if="( $(wpcf-overall-cust-ea-postrat) gt '0' )"}!}
Rating: [format-currency num="{!{types field='overall-cust-ea-postrat' format='FIELD_VALUE'}!}{!{/types}!}" sym=""] {!{/wpv-conditional}!}
Here below the function I use:
function format_my_number($atts)
{
$atts = shortcode_atts(
array(
'num' => '',
'sym' => '',
),
$atts
);
if ($atts['num'] == 0 || $atts['num'] == '0' || $atts['num'] == 'NULL' || $atts['num'] == NULL)
{
$atts = shortcode_atts(
array(
'num' => 1,
'sym' => '@',
),
$atts
);
return $atts['sym'] .$atts['num'];
}
else
{
$num = $atts['num'];
return $atts['sym'].' '.number_format($num - 0.05, 1, ',', '.') ;
}
}
add_shortcode('format-currency', 'format_my_number');
I tried to see forum, documents and resources for developers, disabled lazy loading, but I havent’t found an answer. Do you have any suggesiton about what to check?
Many thanks, Marco.
]]>When logged-in users add an event, they can chose if there is an ending date or if the event is one day only (you can’t see that functionnality for now because I changed it after my client created events).
I added a PHP function to see only the events that take place after the day we see the calendar. I achieved it simply when every event had an ending date, but I am struggling with my code to show one-day events.
You can see my code below :
add_action( 'elementor/query/filter_date', function( $query ) {
$today = date('Ymd');
$meta_query = $query->get( 'meta_query' );
if(empty('ending_date')){
$meta_query = [
[
'key' => 'starting_date',
'value' => $today,
'type' => 'DATE',
'compare' => '>=',
]
];
} else {
$meta_query = [
[
'key' => 'ending_date',
'value' => $today,
'type' => 'DATE',
'compare' => '>=',
]
];
}
$query->set( 'meta_query', $meta_query );
} );
Any idea how I can fix it please?
Thanks
]]>I’m struggling with displaying my ACF Repeater field into single CDATA rows.
This is what i would like to achieve:
<countries>
<![CDATA[ Botswana ]]>
<![CDATA[ Zimbabwe ]]>
</countries>
Currently, it’s displaying like this:
<countries>
<![CDATA[ a:1:{s:4:”land”;s:17:”Botswana|Zimbabwe”;} ]]>
</countries>
I’ve tried writing multiple functions:
<countries>
[my_output_items({Landen})]
</countries>
<?php
function my_output_items( $landen ) {
$pieces = explode("|", $landen);
echo "value: " . $pieces[1] . " ]]>";
}
?>
This returns the following value (on top of the page):
value: Zimbabwe ]]>
So, i feel like i’m getting there, but i really need some help to get further with this. Any advice is highly appreciated.
]]>Thank you for your help !
Best Regards,
Cedric
So I’m manually inserting ads via the theme hooks, wondering which method would you recommend to insert the block on the hook PHP Function OR Shortcode? And yes I have a good amount of traffic.
(and I see that Shortcodes IGNORE individual post/page exceptions!, where i need exceptions too)
For example, this error: “Unexpected token TEXT” comes from when using:
[str_pad({location_zip[1]}, 5, "0", STR_PAD_LEFT)]
But if I change the constant to the integer value, it works fine. Eg:
[str_pad({location_zip[1]}, 5, "0", 0)]
I’m trying to use the PHP function to retrieve a list of products by a given collection id. Therefore I have these two lines of code in my template
$Products = WP_Shopify\Factories\DB\Products_Factory::build();
$result = $Products->get_products_by_collection_ids(164430086192);
where 164430086192 is the code of the collection I want to show the products of.
When I print_r($result) I get an empty array(). If I print_r($Products) I get
WP_Shopify\DB\Products Object ( [table_name_suffix] => wps_products [table_name] => wp_wps_products [version] => 1.0 [primary_key] => id [lookup_key] => product_id [cache_group] => wps_db_products [type] => product [default_product_id] => 0 [default_post_id] => 0 [default_title] => [default_body_html] => [default_handle] => [default_post_name] => [default_image] => [default_images] => [default_vendor] => [default_product_type] => [default_published_scope] => [default_published_at] => 2020-10-21 13:46:32 [default_updated_at] => 2020-10-21 13:46:32 [default_created_at] => 2020-10-21 13:46:32 [default_admin_graphql_api_id] => [default_metafields_global_title_tag] => [default_metafields_global_description_tag] => [metafields_global_title_tag] => [metafields_global_description_tag] => )
Am I using that function correctly?
Many thanks
Jeff
I have a few other plugins that dynamically add code to the generated robots.txt file and I didn’t see any instructions for adding the required blackhole rule dynamically (only instructions for creating the file manually). So for anyone wishing to add the blackhole rule dynamically, adding this code snippet to the functions.php file in the site’s child theme worked for me:
// Add Blackhole for Bad Bots Rule to generated robots.txt file
add_filter('robots_txt', 'machine_robots', 10, 2 );
function machine_robots( $output, $public ) {
$output .= "Disallow: /?blackhole";
return $output;
}
I will post a follow up if this causes any problems…
pk
]]>Thanks and good job
]]>