Reordering elements on front-end
-
Hi. I’ve seen that there’s currently no way of reordering the card elements in the frontend. I don’t know if it’s in your plans or not but I need that for a project so I’ve implemented a filter to allow it and was wondering if it may be useful for a next update (it’s a bit rough):
at class-wpzoom-recipe-card-block.php
$inner_block_content = $recipe_card_image . $recipe_card_heading . $details_content . $summary_text . $ingredients_content . $steps_content . $recipe_card_video . $notes_content . $footer_copyright . $structured_data_json; $inner_block_content=apply_filters('recipe_card_content_items',$inner_block_content,array( 'recipe_card_image'=>$recipe_card_image, 'recipe_card_heading'=>$recipe_card_heading, 'details_content'=>$details_content, 'summary_text'=>$summary_text, 'ingredients_content'=>$ingredients_content, 'steps_content'=>$steps_content, 'recipe_card_video'=>$recipe_card_video, 'notes_content'=>$notes_content, 'footer_copyright'=>$footer_copyright, 'structured_data_json'=>$structured_data_json)); $block_content = sprintf( '<div class="%1$s" id="%2$s">%3$s</div>', esc_attr( trim( $RecipeCardClassName ) ), esc_attr( $id ), $inner_block_content );
and then using the filter in functions.php to i.e. move the video to a different position:
add_filter('recipe_card_content_items','recipe_card_content_items_custom_order',10,2); function recipe_card_content_items_custom_order($inner_block_content,$fragments) { $inner_block = $fragments['recipe_card_heading']. $fragments['recipe_card_video']. $fragments['details_content']. $fragments['summary_text']. $fragments['ingredients_content']. $fragments['steps_content']. $fragments['notes_content']. //$fragments['footer_copyright']. $fragments['recipe_card_image']. $fragments['structured_data_json']; return $inner_block; }
- The topic ‘Reordering elements on front-end’ is closed to new replies.