Support

Account

Forum Replies Created

  • Your link resolved my problem.

    Damiane Muller :

    I did a search and replace on the wp_usermeta table for the typo and replaced it with the correct spelling. I then went into the checkbox field setting and fixed the typo. After that I checked any users who had the typo selected and their choice had updated (and remained checked)!

    Thank you John

  • Hello John,

    Thank you for your reply.

    I will try your link and make a feedback later.

    Regards.

  • I succeeded in realize what i wanted. But i don’t know if it’s safe way :

    <?php function sidebar_related() { 
    <strong>ob_start();</strong>
    $type = get_field( "themes", get_the_ID() );
    $args = array(
    'post_type' => 'post',
    'posts_per_page' => -1,
    'orderby' => 'date',
    'post__not_in' => array(get_the_ID()),
    'order' => 'DESC',
    
    'meta_query' => array(
    array(
    'key' => 'themes',
    'value' =>  $type
    )
    ),
    );
    $my_posts = new WP_Query($args); ?>
      <ul>                                             
    <?php if ( $my_posts->have_posts() ) : while ( $my_posts->have_posts() ) : $my_posts->the_post(); ?>
               <li><a href="<?php the_permalink(); ?>"><?php the_title() ;?></a></li>
                
    <?php endwhile; ?>
    </ul>
    
    <?php endif; 
    wp_reset_postdata();
    <strong>$output_string = ob_get_contents();
    ob_end_clean();
    return $output_string;</strong>
    }
     
    add_shortcode('related-terms', 'sidebar_related');

    Any idea ?

  • Ok, i resolve the problem not to display in the list the title of the current post :

    <?php
    function sidebar_related() { 
    $type = get_field( "themes", get_the_ID() );
    $args = array(
    'post_type' => 'post',
    'posts_per_page' => -1,
    'orderby' => 'date',
    'post__not_in' => array(get_the_ID()),
    'order' => 'DESC',
    
    'meta_query' => array(
    array(
    'key' => 'themes',
    'value' =>  $type
    )
    ),
    );
    $my_posts = new WP_Query($args); ?>
                                                   
    <?php if ( $my_posts->have_posts() ) : while ( $my_posts->have_posts() ) : $my_posts->the_post(); ?>
               <a href="<?php the_permalink(); ?>"><?php the_title() ;?></a>
                
    <?php endwhile; else : ?> 
                 <p><?php _e( 'No Posts To Display.' ); ?></p>
    <?php endif; 
    }
     
    add_shortcode('related-terms', 'sidebar_related');
    ?>

    To complete, anyone has an idea to display my shortcode [related-terms] in the right place ?

    I can’t understand why is out of its module…

  • I succeeded to have a beginning of resukt with :

    function sidebar_related() { 
    $type = get_field( "themes", get_the_ID() );
    $args = array(
    'post_type' => 'post',
    'posts_per_page' => -1,
    'orderby' => 'date',
    'order' => 'DESC',
    
    'meta_query' => array(
    array(
    'key' => 'themes',
    'value' =>  $type
    )
    ),
    );
    $my_posts = new WP_Query($args); ?>
                                                   
    <?php if ( $my_posts->have_posts() ) : while ( $my_posts->have_posts() ) : $my_posts->the_post(); ?>
               <a href="<?php the_permalink(); ?>"><?php the_title() ;?></a>
                
    <?php endwhile; else : ?> 
                 <p><?php _e( 'No Posts To Display.' ); ?></p>
    <?php endif; 
    }
     
    add_shortcode('related-terms', 'sidebar_related');

    Is it possible not to display in the list the title of the current post ?

    Thank you !

  • EDIT :

    I use the DIVI builder and try to realize that query as shortcode in a TXT module.

    I can’t understand why the results don’t display properly in this right place.

    The problem

    Thank you again

  • Ok, i resolve myself my problem.
    My new code is :

    <?php
    
    /*
    Template Name: Comptes rendus
    */
    
    get_header();
    
    $show_default_title = get_post_meta( get_the_ID(), '_et_pb_show_title', true );
    
    $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );
    
    ?>
    
    <div id="main-content">
    	<?php
    		if ( et_builder_is_product_tour_enabled() ):
    			// load fullwidth page in Product Tour mode
    			while ( have_posts() ): the_post(); ?>
    
    				<article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>
    					<div class="entry-content">
    					<?php
    						the_content();
    					?>
    					</div> <!-- .entry-content -->
    
    				</article> <!-- .et_pb_post -->
    
    		<?php endwhile;
    		else:
    	?>
    	<div class="container">
    		<div id="content-area" class="clearfix">
    			<div id="left-area">
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php
    				/**
    				 * Fires before the title and post meta on single posts.
    				 *
    				 * @since 3.18.8
    				 */
    				do_action( 'et_before_post' );
    				?>
    				<article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>
    					<?php if ( ( 'off' !== $show_default_title && $is_page_builder_used ) || ! $is_page_builder_used ) { ?>
    						<div class="et_post_meta_wrapper">
    							<h1 class="entry-title"><?php the_title(); ?></h1>
    						</div> <!-- .et_post_meta_wrapper -->
    				<?php  } ?>
    
    					<div class="entry-content">
    					<?php
    						do_action( 'et_before_content' );
    			
    
    $query2021 = new WP_Query( array( 
    'post_type' => 'comptes-rendus',
    'orderby' => 'date',
    'order'   => 'DESC',
    'meta_query' => array(
    						array( 
    						'key' => 'annee', // name of custom field
    						'value' => '2021', // matches exaclty "123", not just 123. This prevents a match for "1234"
    						'compare' => 'LIKE' 
    					)
    )
    )
    );
    						// The Query
    if ( $query2021->have_posts() ) : ?>
    <div class="entry-content" itemprop="text">
    <table class="table-cr">
      <thead>
        <tr>
          <th scope="col">Intitulé</th>
          <th scope="col">Date</th>
          <th scope="col">Fichier</th>
          <th scope="col">Poids</th>
        </tr>
      </thead>
    <?php // The Loop
    $file = get_field('fichier');
    while ( $query2021->have_posts() ) : $query2021->the_post(); ?>
      <tbody>
        <tr>
          <td data-label="Intitulé"><?php the_field('intitule'); ?></td>
          <td data-label="Date"><?php the_time( 'j.m.Y' ); ?></td>
          <td data-label="Fichier"><a href="<?php the_field('fichier'); ?>" target="_blank" ><button>Télécharger</button></a></td>
    	  <td data-label="Poids"><?php the_field('poids'); ?></td>
        </tr>
    
    </tbody>
    <? endwhile; ?>
    </table>
    </div>
    <?php endif ;
    
    $query2020 = new WP_Query( array( 
    'post_type' => 'comptes-rendus',
    'orderby' => 'date',
    'order'   => 'DESC',
    'meta_query' => array(
    						array( 
    						'key' => 'annee', // name of custom field
    						'value' => '2020', // matches exaclty "123", not just 123. This prevents a match for "1234"
    						'compare' => 'LIKE' 
    					)
    )
    )
    );
    						// The Query
    if ( $query2020->have_posts() ) : ?>
    <div class="entry-content" itemprop="text">
    <table class="table-cr">
      <thead>
        <tr>
          <th scope="col">Intitulé</th>
          <th scope="col">Date</th>
          <th scope="col">Fichier</th>
          <th scope="col">Poids</th>
        </tr>
      </thead>
    <?php // The Loop
    $file = get_field('fichier');
    while ( $query2020->have_posts() ) : $query2020->the_post(); ?>
      <tbody>
        <tr>
          <td data-label="Intitulé"><?php the_field('intitule'); ?></td>
          <td data-label="Date"><?php the_time( 'j.m.Y' ); ?></td>
          <td data-label="Fichier"><a href="<?php the_field('fichier'); ?>" target="_blank" ><button>Télécharger</button></a></td>
    	  <td data-label="Poids"><?php the_field('poids'); ?></td>
        </tr>
    
    </tbody>
    <? endwhile; ?>
    </table>
    </div>
    <?php endif; wp_reset_postdata(); ?>
    					
    					
    					</div> <!-- .entry-content -->
    					<div class="et_post_meta_wrapper">
    					<?php
    					
    					/**
    					 * Fires after the post content on single posts.
    					 *
    					 * @since 3.18.8
    					 */
    					do_action( 'et_after_post' );
    
    						
    					?>
    					</div> <!-- .et_post_meta_wrapper -->
    				</article> <!-- .et_pb_post -->
    
    			<?php endwhile; wp_reset_postdata(); ?>
    			
    			</div> <!-- #left-area -->
    
    			<?php get_sidebar(); ?>
    		</div> <!-- #content-area -->
    	</div> <!-- .container -->
    	<?php endif; ?>
    </div> <!-- #main-content -->
    
    <?php
    
    get_footer();

    Thank you !

  • Ok, it works with :

    <?php $terms = get_the_terms( $auteur->ID, 'auteur' ); 
    foreach($terms as $term) {
    $term_link = get_term_link( $term );
    echo '<a href="' . esc_url( $term_link ) . '">' . $term->name . '</a>';
    } ?>

    Thank you John

  • Then, is it possible to do without the taxonomy field and only use the custom taxonomy ?

  • No, haven’t this field.
    But if i create this field, i have twice checkboxes in CPT “membres” : this one of the Custom taxonomy and this one of the taxonomy field

  • Hello John,

    In fact, “auteur” is a Custom taxonomy for the CPT “membres”. It’s not a field…

  • I try this in other way…

  • Thank you for your answer John.

    It seems that the problem is Varnish cache from my host.

    Varnish HTTP Purge seems does the trick.

    regards

  • INFO : it’s a fresh wordpress install without plugins or cache system.

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