• Hello,
    I try to change :
    <?php echo do_shortcode( '[ingredients]' ) ?>

    This is a multiple values list, but I don’t manage to change it.

    The shortcode is here :

    // [ingredients] short code
    function show_ingredients($atts, $content = null) {
    
    	extract(shortcode_atts(array(
    									'title' => ''
    								), $atts));
    
    	global $post;		
    
    	$ingredients = get_post_meta($post->ID, 'RECIPE_META_ingredients');	
    
    	$ingredients_count = count($ingredients[0]);
    
    	if(empty($title))
    	{
    		$ingredients_html = '<h3>'.__('Ingredients','woothemes').'</h3>';
    	}else{
    		$ingredients_html = '<h3>'.$title.'</h3>';
    	}
    
    	if( $ingredients_count >= 1 && (!empty($ingredients[0][0])) )
    	{
    		$i = 0;
    		$ingredients_html .= '<ul class="ingre">';
    
    		while($i < $ingredients_count)
    		{
    			$ingredients_html .= '<li> ';
    			$ingredients_html .= $ingredients[0][$i];
    			$ingredients_html .= '</li>';
    			$i++;
    		}
    
    		$ingredients_html .= '</ul>';
    	}
    	else
    	{
    		$ingredients_html .= '<p>';
    		$ingredients_html .= __('No Ingredients Found ! ','woothemes');
    		$ingredients_html .= '</p>';
    	}
    
    	return $ingredients_html;
    
    }
    add_shortcode('ingredients', 'show_ingredients');

    I tried to change almost anything but I don’t manage to succeed.

    For example the :

    <ul>
    <?php
    $values = get_editable_post_meta( get_the_ID(), 'my_key' );
    foreach ( $values as $value )
        echo '<li>' . $value . '</li>';
    ?>
    </ul>

    make this error :
    Warning: scalar expected. array given in /homepages/3/d440635061/htdocs/recette-vegan/wp-content/plugins/front-end-editor/php/fields/base.php on line 78
    The only thing I can modify is the word Array…

    Can someone help me ?
    Thank you

    https://wordpress.org/plugins/front-end-editor/

Viewing 1 replies (of 1 total)
  • Thread Starter nicart

    (@nicart)

    Of course the code added was :

    <?php
    $values = get_editable_post_meta(get_the_ID(), 'RECIPE_META_ingredients' );
    foreach ( $values as $value )
        echo '<li>' . $value . '</li>';
    ?>

Viewing 1 replies (of 1 total)

The topic ‘Problem with custom post & shortcode’ is closed to new replies.