Support

Account

Forum Replies Created

  • Well I guess I’m not sure what to do now since I can’t get this to work.

  • Well shortly after I posted above, there is not custom field posting. It’s just a broken URL. I’ve attached a series of images I hope someone can understand why this isn’t working.

    code to post independent of functions: this code is within a ‘front-page.php’ template. No different than these instructions: https://www.advancedcustomfields.com/resources/image/ and code examples https://www.advancedcustomfields.com/resources/code-examples/

    code in functions: the code you provided above

    custom-field: the custom field’s settings.

  • I see the problem: for some reason the Custom field was set to ‘disabled’.

    Thank you for your help, James.

  • Great! The error went away, but now the Custom field I created will not show in the widget editor.

    Shall I post in another forum section?

  • Thank you, James.

    Taking your advice, I’m experiencing this error:

    Parse error: syntax error, unexpected ';', expecting ')' in /home/tempestus/public_html/wp-content/themes/xxxxxx/functions.php on line 137

    My code (line 137 is the ‘before_widget’ code):

    $backgroundimage = get_field('widget_background_image');
    
    	register_sidebar( array(
    		'name'          => __( 'Widgets', 'tempestcorp' ),
    		'id'            => 'page-widget',
    		'description'   => __( 'Appears on any of the assigned pages.', 'tempestcorp' ),
    		'before_widget' => '<section id="%1$s" class="widget %2$s"><div style="background-image: url(' . $backgroundimage['url']; . ');">',
    		'after_widget'  => '</div></section>',
    		'before_title'  => '<h2 class="widget-title">',
    		'after_title'   => '</h2>',
    	) );
  • I little bit beyond by knowledge, but I’ll give it a go.

  • This worked very nicely, James. THANK YOU! I was struggling for a few days on this.

    Final code, with your modifications:

    <div class="industries group">
                <?php
                    // vars
                    $rows = get_field('repeater', 691);
    			?>
                 
                <?php if( have_rows('repeater', 691) ): ?> 
    
    				<?php while( have_rows('repeater', 691) ): the_row();
    					$pagelink = get_sub_field('page_link');
                        $image = get_sub_field('image');
                        $title = get_sub_field('title');
    				?>
            		
                       <div class="indus col-sm-3">
                          <p><a href="<?php echo $pagelink; ?>"><img style="max-width: 100%; height:auto" src="<?php echo $image; ?>" /><?php echo $title; ?></a></p>
                      </div>
    
                <?php endwhile; ?>
                       
                <?php endif; ?>
                
    </div><!--end container-->

    YOU GUYS ARE GREAT!

  • Thank you.

    This worked:

    <div class="header-background">
    <?php 
    $image = get_field('background_image', 445);            
    if( !empty($image) ): ?>            
    <div style="background: url('<?php echo $image; ?>');"></div>
    <?php endif; ?>
    </div>
  • Result attached.

  • Based on the screenshot, the Location Rule is “Post Type = wysiwyg-widget”.

    Widget Block ID = 691
    Custom Field Group ID = 687

    So with that, the code should look like this:

    <?php if( the_field('Industries Widget Blocks', 687) ): ?>
    <div class="industries group">
                <?php
                    // vars
                    $rows = get_field('repeater', 691);
                    $pagelink = get_sub_field('page_link', 691);
                    $image = get_sub_field('image', 691);
                    $title = get_sub_field('title', 691);
            ?>
                 
                <?php if( have_rows('repeater', 691) ): ?>
    
                 <?php while( have_rows('repeater', 691) ): the_row(); ?>
            
                       <div class="indus col-sm-3">
                          <p><a href="<?php $pagelink; ?>">
                        <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /><?php echo $title; ?></a></p>
                      </div>
    
                <?php endwhile; ?>
                       
                <?php endif; ?>
                
                   </div><!--end container-->
                 
    <?php endif; ?><!--end 'repeater' if-->

    With that being said, I still cannot get the content to post. I have requested assistance from the plugin developer for further information.

  • Yes, well, that’s where I’m a tad confused. I’m using a repeater in a Widget Block and supplied images of what my Widget Block and Widget look like and the code at the bottom. Using the below code, nothing is posting.

    My code:

    <?php if( the_field('Industries', 691) ): ?>
    <div class="industries group">
                <?php
                    // vars
    				$rows = get_field('repeater');
                    $pagelink = get_sub_field('page_link');
                    $image = get_sub_field('image');
    				$title = get_sub_field('title');
            ?>
                 
                <?php if( have_rows('repeater') ): ?>
    
    	         <?php while( have_rows('repeater') ): the_row(); ?>
    		
    			       <div class="indus col-sm-3">
    				  	<p><a href="<?php $pagelink; ?>">
                        <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /><?php echo $title; ?></a></p>
                      </div>
    
                <?php endwhile; ?>
                       
        	    <?php endif; ?>
                
           		</div><!--end container-->
                 
    <?php endif; ?><!--end 'repeater' if-->
    
  • Okay. On top of that, I’m unsure of how to display the content after creating the widget.

  • Found it. I never realized that the post-type was ‘wysiwyg-editor’.

  • That’s definitely a cleaner way of setting up this code using the assigned variables and easier to understand it’s functionality.

    Thank you for clearing AND cleaning this up. This works great!

  • This seems to work, but it seem rather redundant:

    <article id="blue" <?php post_class(); ?>>
    
                <?php
    				if( have_rows('text_section') ):
    					while ( have_rows('text_section') ) : the_row(); 
    				$title	= get_sub_field('title');
    				$text	= get_sub_field('text');
    				$texts	= get_sub_field('text_copy');
    				$cols	= get_sub_field('columns');
                ?>
                        
               <div class="container">
    					
                <?php
    						if(get_sub_field('columns') == "1") : ?>
    						
                                <div class="entry-header">
                                    <h1 class="entry-title"><?php the_sub_field('title'); ?></h1>
                                </div>
                                
                                <?php the_sub_field('text'); ?>
                                
                                <?php elseif( get_sub_field('columns') == "2") : ?>
                                                
                                <div class="entry-header">
                                    <h1 class="entry-title"><?php the_sub_field('title'); ?></h1>
                                </div>
                                
                              <div class="col-sm-6">
                                    <?php the_sub_field('text'); ?>
                                </div>
                                <div class="col-sm-6">
                                	<?php the_sub_field('text_copy'); ?>
                                </div>
    						
    						<?php endif;
    					
    					endwhile;
    				endif;
                ?>
                </div>
    </article>
    
  • Looks to me like it is:

    <article id="blue" <?php post_class(); ?>>
                <?php
    				if( have_rows('text_section') ):
    					while ( have_rows('text_section') ) : the_row(); 
    
    				$title	= get_sub_field('title');
    				$text	= get_sub_field('text');
    				$texts	= get_sub_field('text_copy');
    				$cols	= get_sub_field('columns');
                ?>
            
                <div class="entry-header">
    	            <h1 class="entry-title"><?php the_sub_field('title'); ?></h1>
                </div>
                
               <div class="container">
    					
                <?php
    						if(get_sub_field('columns') == "1") : ?>
    						
                                <?php the_sub_field('text'); ?>
                                
                                <?php elseif( get_sub_field('columns') == "2") : ?>
                                
                                <div class="col-sm-6">
                                    <?php the_sub_field('text'); ?>
                                </div>
                                <div class="col-sm-6">
                                	<?php the_sub_field('text_copy'); ?>
                                </div>
    						
    						<?php endif;
    					
    					endwhile;
    				endif;
                ?>
                </div>
    </article>
  • Okay…I thought I figured it out using this (fix.PNG), but it still posts one blank repeated ‘entry-header’ field and one filled in. hmmm…

    You can see where I’m working here.

  • That’s exactly the thought that I’m trying to do. But when I use your code, nothing posts. So I modified it a tad (first-step.PNG).

    With this modification, it seems that the

                <div class="entry-header">
    	            <h1 class="entry-title"><?php the_sub_field('title'); ?></h1>
                </div>

    is repeating, which it should only post one time.

    A screenshot of what it looks like in code view is attached (result.PNG). I’m thinking it’s posting twice because it’s within a loop. But if I move it: (second-step.PNG), the title won’t post.

  • If any fields you reference are INSIDE the flexibile content, you need to use the_sub_field() or get_sub_field() to see any content.

    I think this would be one reason why (when I tried your method), only one column of content is posting and not both. I’m only getting the second column of data because of the way I’m requesting it. So in that case, I would nee to change this

    <?php elseif( get_sub_field('columns') == "2") : ?>
                                        
                                        <div class="entry-header">
                                            <h1 class="entry-title"><?php the_title(); ?></h1>
                                        </div>
                                        <div class="blue">
                                            <div class="col-sm-6">
    											<?php the_sub_field('title'); ?>
                                                <?php the_sub_field('text_copy'); ?>
                                            </div>
    								
    								<?php endif;

    to this?
    <?php elseif( get_sub_field('columns') == "1" && == "2") : ?>

    Which doesn’t seem like a good idea to use. Based upon the way I’ve developed this:
    Fields

    There should be a more viable solution to post both columns without using ‘&&’.

  • Thank you.

    So based upon your code, would you say that I was making more work for myself combining the two conditions the way I did it?

    Because looking at the ‘Select’ page, there are more conditions involved in posting the data with the use of the

    if( get_row_layout() ==

  • I was trying to find the FIRST post I made and remove it so as not be flagged for ‘spamming’ since I’ve been making attempts to find the solution. But it doesn’t look like I can remove my posts.

    Thank you.

  • Well that took care of the problem. Now I need to figure out why my content won’t post! Back to work!

  • Here you are.

Viewing 25 posts - 26 through 50 (of 67 total)