Support

Account

Forum Replies Created

  • Hello again,

    changing the name of the variable $block to something else in the foreach head fixed the error message.

    Example:

    
    			$blocks = parse_blocks( get_the_content() );
    			foreach ($blocks as $blockcontent) {
    				if( 'acf/blockname' == $blockcontent['blockName'] ) {
    					
    					
    					if( !empty( $blockcontent['attrs']['data']['field_name'] ) ) {
    						$title = $blockcontent['attrs']['data']['field_name'];
    						echo '<p>'. $title .'</p>';
    						break;
    					}
    					
    				}
    			}
    

    Maybe someone can explain me that? Thanks again.

  • Found a solution for me with array_push:

    
    if ( have_rows( 'module_post') ):
    
    $stackWords = array();
    
     while ( have_rows( 'module_post') ) : the_row();
    
      if ( get_row_layout() == 'module_text' ) : // Text
    
    	$content = get_sub_field( 'module_post' );
    	array_push($stackWords, $content);
    	
      endif;
    
     endwhile;
    
    $words = implode( ", ", $stackWords );
    $word_count = str_word_count( strip_tags( $words ) );
    //$readingtime = ceil($word_count / 200);
    //echo $word_count;
    
    endif; //module_post
    

    If there a better solution, let me know. thank you!

  • <?php
    $string = array("string-1","string-2","string-3","string-4" );
    $replace = array("new-string-1","new-string-2","new-string-3","new-string-4");
    $fieldname = get_field('fieldname', $term); // it is a meta-field for a taxonomy term
    $replaces = str_replace($string , $replace , $fieldname);
    
    foreach ($replaces as $wert)
    {
      echo $wert . ',';
    }
    ?>

    Sorry, that was not my day.

Viewing 3 posts - 1 through 3 (of 3 total)