Forums Forums Search Search Results for 'get_field('

Viewing 10 results - 41 through 50 (of 90 total)
  • Author
    Search Results
  • #206079

    In reply to: Shortcodes in excerpt


    Trevor
    Participant

    Did you try wrapping that code in a do_shortcode function?

    <?php if( get_field('my_custom_field') ):?>
    <p>My Custom Field Value: <?php do_shortcode(the_field('my_custom_field')); ?></p>
    <?php endif; ?>

    I am not sure if that would work. Otherwise you may need to use PHP string functions to fetch the string as before, then split it up into before the button shortcode, the shortcode and the what comes after, and then handle them, with the shortcode being output in a do_shortcode function.

    #205982

    In reply to: Shortcodes in excerpt


    Anonymous
    Inactive

    Is the page loading using Ajax? If so, that will be the issue, as the player you are using needs reinitialising after an Ajax load. What player are you using?

    I am using Ajax to load the page. I am using standard WP audio shortcode.
    I turned Ajax off and all is good now. Thanks!

    <?php if( get_field(‘my_custom_field’) ):?>
    <p>My Custom Field Value: <?php the_field(‘my_custom_field’); ?></p>
    <?php endif; ?>

    thanks, I will try

    PS Very good support speed!

    #205978

    In reply to: Shortcodes in excerpt


    Trevor
    Participant

    Is the page loading using Ajax? If so, that will be the issue, as the player you are using needs reinitialising after an Ajax load. What player are you using?

    As to ACF fields. Let us assume it is a single value field use key is my_custom_field and the prefix required is My Custom Field Value, then the PHP is this:

    <?php if( get_field('my_custom_field') ):?>
    <p>My Custom Field Value: <?php the_field('cial_secteur'); ?></p>
    <?php endif; ?>

    Anonymous
    Inactive

    Hi there,

    I’d like to use the infinite scroll mechanism in combination with masonry and the shortcode function.

    The results url points definitely pointed to the write page. And the following settings should be correct either.

    Post / Result Selector: article
    Infinite Scroll Container: .archive-query__inner

    And this is my custom results template.

    <?php if ( $query->have_posts() ): ?>
    		<div class="masonry archive-query__inner entry-content">
    			<?php while ($query->have_posts()) : $query->the_post(); $kategorie_term = get_field( 'kategorie' ); ?>
    			<article class="object <?php if ( $kategorie_term && $kategorie_term->name !== 'Fact' ) { echo 'object--blue tagged'; } elseif ( $kategorie_term->name == 'Fact' ) { echo 'object--yellow tagged'; } else { echo 'object--blue'; } ?>" id="post-<?php the_ID(); ?>">
    				<a href="<?php the_permalink(); ?>">
    					<div class="lazyload object__inner" data-bg="<?php if ( $kategorie_term->name == 'Fact' ) { echo the_field( 'factbild' ); } else { echo get_the_post_thumbnail_url(); } ?>" id="post-<?php the_ID(); ?>">
    						<?php if ( $kategorie_term ): ?>
    						<div class="overline">
    							<h6><?php echo $kategorie_term ->name; ?></h6>
    						</div>
    						<?php endif; ?>
    
    						<div class="object__inner__text content-no-margin">
    							<?php if ( $kategorie_term && $kategorie_term->name !== 'Fact' ) { echo '<h3>' . get_the_title() . '</h3>'; } elseif ( $kategorie_term->name == 'Fact' ) { echo '<h3>' . get_field( 'facttext' ) . '</h3>'; } else { echo '<h4>' . get_the_title() . '</h4>'; } ?>
    							<p class="textlink" href="<?php the_permalink(); ?>">Mehr erfahren</p>
    						</div>
    					</div>
    				</a>
    			</article>
    			<?php endwhile; ?>
    		</div>
    		<?php else: ?>
    		<div class="search-filter-results-list" data-search-filter-action="infinite-scroll-end">
    			<span>Keine Einträge gefunden...</span>
    		</div>
    		<?php endif; ?>

    Thank you in advance for your help!


    Anonymous
    Inactive

    Hi Trevor,

    My first post maybe wasn’t that clear. I apologize. We’re using a custom WP query for this page to show all the activities (activiteiten). When clicking the ‘bekijk activiteit’ button on the activiteiten page it show an error in console from Google Chrome devtools (error in first post) and we can’t figure out what’s causing it.

    The button is working (forwarding to the detail page) when we turn off the ajax setting in the S&F settings.

    This is our custom post type:

    <?php
    
    $atts = shortcode_atts(
    	[
    		'number'    => -1,
    		'orderby'   => 'menu_order',
    		'category' => '',
    	],
    	$atts,
    	'alle_activiteiten'
    );
    
    $numberposts = $atts['number'];
    $order_by    = $atts['orderby'];
    $category    = $atts['category'];
    
    // args.
    $args = array(
    	'post_type'      => 'activiteit', // CPT slug.
    	'posts_per_page' => $numberposts,
    	'post_status'    => 'publish',
    	'orderby'        => $order_by,
        'order'          => 'ASC',
    	'search_filter_id' => 125,
    	'show' => 'results',
    	/*'tax_query'      => array(
    		array(
    			'taxonomy' => 'my_category_slug',
    			'field'    => 'slug',
    			'terms'    => $category,
    			'operator' => 'AND',
    		),
    	),*/
    );
    
    $activiteiten = new WP_Query( $args );
    
    if ( $activiteiten->have_posts() ) :
    	while ( $activiteiten->have_posts() ) :
    		$activiteiten->the_post(); ?>
    	<div class="alleKamersBlok bmargin">
    		<div class="alleKamersImage">
    			<?php the_post_thumbnail('medium-large'); ?>
    		</div>
    		<div class="alleKamersText activiteitenText">
    			<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    			<h4 class="cat"><?php echo get_field("activiteiten_soort_activiteit"); ?></h4>
    			<p><?php echo get_the_content(); ?></p>
                <div class="buttonContainer"><a itemprop="url" href="<?php the_permalink(); ?>" target="_self" class="qbutton  default" style="">Bekijk activiteit</a></div>
    			
    		</div>
    	</div>
    	
    
    		<?php
    	endwhile;
    	wp_reset_postdata();
    
    else :
    	_e( 'Woops! Niks gevonden.', 'flux' );
    endif;
    ?>

    Hope this clears things up.

    #201589

    Trevor
    Participant

    Maybe my code and suggestion was almost corect, but it needs the post ID, like this:

    <?php $textobt = get_field('texto_boton', get_the_ID() ); ?>

    #200172

    Anonymous
    Inactive

    The data is blank after the search, you are right. Thank-you for your help so far, what do you suggest?

    Array
    (
    [post_type] =>
    [search_filter_id] =>
    )

    ;

    
          <?php
          $postType = get_field('post_type', get_the_ID());
          $searchId = get_field('search_id', get_the_ID());
    
          echo do_shortcode('[searchandfilter id="'.$searchId.'"]'); 
          ?>
    
          <div class="buy-wrapper" id="search-results">
          <?php
          $args = array('post_type' => $postType);
          $args['search_filter_id'] = $searchId;
          ?>
          <pre><?php print_r($args);?></pre>;
    
          <?php
          
          $category_posts = new WP_Query($args);
    
          if($category_posts->have_posts()) : 
            while($category_posts->have_posts()) : 
               $category_posts->the_post();
          ?>
    #200161

    Anonymous
    Inactive

    I have made the code a little cleaner, I tried get_the_ID() and this did not work, I also have taken the variables out of the AJAX container (#search-results) and still get the same issue.

    The form in the first line does work fine, it is literally just the results that go to all uncategorised. Echoing those 2 args, produces the correct array and ID.

    
          <?php
          $postType = get_field('post_type', get_the_ID());
          $searchId = get_field('search_id', get_the_ID());
    
          echo do_shortcode('[searchandfilter id="'.$searchId.'"]'); 
    
          $args = array('post_type' => $postType);
          $args['search_filter_id'] = $searchId;
    
          print_r($args = array('post_type' => $postType));
          echo $args['search_filter_id'] = $searchId;
          ?>
    
          <div class="buy-wrapper" id="search-results">
          <?php
          $category_posts = new WP_Query($args);
    
          if($category_posts->have_posts()) : 
            while($category_posts->have_posts()) : 
               $category_posts->the_post();
          ?>
    #200155

    Trevor
    Participant

    Is it just these two lines that do not work?

    $args = array('post_type' => get_field('post_type'));
    $args['search_filter_id'] = get_field('search_id');

    If you use an echo with a message to prefix those lines, do the post type and id output or are they empty?

    Does the form in the first line of the code output OK?

    What happens if you add the Post ID as the second argument. E.g.

    $args = array('post_type' => get_field('post_type', get_the_ID()));
    $args['search_filter_id'] = get_field('search_id', get_the_ID());
    #199084

    Trevor
    Participant

    Try moving this line:

    <?php $textobt = get_field('texto_boton'); ?>
    

    To immediately after this line:

    $query->the_post();
    
Viewing 10 results - 41 through 50 (of 90 total)