Skip to main content
added code
Source Link
timholz
  • 151
  • 1
  • 1
  • 13

Hi – in my theme (mystile) i am limited to determine the number of featured products displayed on the homepage. But I cannot assign the columns. Shortcode does not apply because the homepage is generic and cannot be altered in the backend. I can, of course change the number of columns in the plugin source file (class-wc-shortcode.php, line 76), but that will be lost with the next update. I am not very good with php and i scanned similar questions. I tried several methods to filter this value but none of them worked. Here is my approach:

/*different values for featured prod shortcode*/
function my_shortcode_val( $atts ) {
$atts = shortcode_atts( array(
        'per_page' => '12',
        'columns'  => '2',
        'orderby'  => 'date',
        'order'    => 'desc'
    ), $atts );
return $atts;
}
add_filter( 'featured_products', 'my_shortcode_val' );

But that does not work. Is there a way to override the value for columns or any shortcode value? Thanks for your help.

Hi – in my theme (mystile) i am limited to determine the number of featured products displayed on the homepage. But I cannot assign the columns. Shortcode does not apply because the homepage is generic and cannot be altered in the backend. I can, of course change the number of columns in the plugin source file (class-wc-shortcode.php, line 76), but that will be lost with the next update. I am not very good with php and i scanned similar questions. I tried several methods to filter this value but none of them worked. Is there a way to override the value for columns or any shortcode value? Thanks for your help.

Hi – in my theme (mystile) i am limited to determine the number of featured products displayed on the homepage. But I cannot assign the columns. Shortcode does not apply because the homepage is generic and cannot be altered in the backend. I can, of course change the number of columns in the plugin source file (class-wc-shortcode.php, line 76), but that will be lost with the next update. I am not very good with php and i scanned similar questions. I tried several methods to filter this value but none of them worked. Here is my approach:

/*different values for featured prod shortcode*/
function my_shortcode_val( $atts ) {
$atts = shortcode_atts( array(
        'per_page' => '12',
        'columns'  => '2',
        'orderby'  => 'date',
        'order'    => 'desc'
    ), $atts );
return $atts;
}
add_filter( 'featured_products', 'my_shortcode_val' );

But that does not work. Is there a way to override the value for columns or any shortcode value? Thanks for your help.

Source Link
timholz
  • 151
  • 1
  • 1
  • 13

Overriding shortcode $atts for featured products

Hi – in my theme (mystile) i am limited to determine the number of featured products displayed on the homepage. But I cannot assign the columns. Shortcode does not apply because the homepage is generic and cannot be altered in the backend. I can, of course change the number of columns in the plugin source file (class-wc-shortcode.php, line 76), but that will be lost with the next update. I am not very good with php and i scanned similar questions. I tried several methods to filter this value but none of them worked. Is there a way to override the value for columns or any shortcode value? Thanks for your help.