Forum Replies Created

Viewing 15 replies - 16 through 30 (of 32 total)
  • Hi @smeeds ,
    i found the solution.
    in Callback php file add in attributes:

    $className = $attributes['className'];

    then in the container add:
    $posts.=' <div class="container '.$className.'">';

    Done!

    To see the generated class you can add in the attributes:

    var_dump($attributes);

    and in the $attributes you will find a className item with the class name of the selected style.

    Regards

    Denis

    Hi @smeeds ,
    I’m also trying to solve this problem but I haven’t found a solution. Have you solved it?

    Theme Author Franchi Denis

    (@franchidesign)

    Hi,
    yes we have solved this problem.

    Regards

    Denis

    Theme Author Franchi Denis

    (@franchidesign)

    Hi @james215,
    For the support of the Theme Pro you can request assistance as indicated in the documentation of the Theme, thanks.

    Regards

    Denis

    Thread Starter Franchi Denis

    (@franchidesign)

    Great, thanks this information is very useful to me too.

    Thread Starter Franchi Denis

    (@franchidesign)

    Hi @munirkamal, I just tried the Twentytwentyone theme which has the ability to show both the expert and all the content of the Posts in the archive (index). If you try to put 2 Progress Bars in a post you will see that they don’t work in the archive …. while in the single post it works correctly. Now I’m designing another theme and haven’t had a chance to test it on Custom Post Types, but you’ll see it will return the same error ..
    Same problem happens with background colors and other Plugin controls as well.

    Regards

    Denis

    Thread Starter Franchi Denis

    (@franchidesign)

    I solved it, by adding this code before line 429:
    $_POST['page'] = isset( $_POST['page'] ) ? $_POST['page'] : 0;

    Thread Starter Franchi Denis

    (@franchidesign)

    Hello,
    finally it works, thanks also to your help.

    I worked all night and now it works perfectly.
    Here is the code:

    <div class="container">
        <div class="row">
          <!-- Query Post Portfolio-->
          <?php
          $portfolio = new WP_Query( array(
            'posts_per_page' => 6,
            'paged' => get_query_var( 'paged' )
          ) );
          
          if( $portfolio->have_posts() ) {
            while( $portfolio->have_posts() ) {
              $portfolio->the_post();
              global $wp_query;
              $meta_value = $wp_query->post->ID;
              ?>
              <div class="<?php
              if( !empty( $meta_value ) ) {
                 echo esc_attr(get_post_meta($meta_value, 'meta-select', true));
              }
              ?>  col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
              <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?>
            </div>
            
            <?php
          }
          wp_reset_postdata();
        }
        ?>
        
      </div>
    </div>
    

    Thanks again for the help and for my english !!!!
    🙂 🙂

    • This reply was modified 7 years, 9 months ago by Franchi Denis.
    Thread Starter Franchi Denis

    (@franchidesign)

    I want to thank you for the help you are giving me!
    For example, the function I want to create serves to set up a different layout with a simple customer selection.
    For example, I would like to create a selection with these options:
    -3-column portfolio (col-md-4),
    -4-column portfolio (col-md-3),
    -2-column portfolio (col-md-6)
    These selectable options should change the value of all posts in the selected category for that type of portfolio.
    I could do it from the customizer but it would be more limited, that is, doing it with the meta box would be more intuitive and above all the user could to each new page created for the portfolio select a different layout.
    I can not understand why this code not function. The code I created put out of the loop works perfectly, however I will try again, I have a hard head !! 🙂
    Sorry for my bad english!

    Thread Starter Franchi Denis

    (@franchidesign)

    Hello @angelch,
    your code does not work.

    @bcworkz kindly you could post the code of the template that works with the save code?
    So I try if it works on my theme too.
    Thank you so much

    • This reply was modified 7 years, 9 months ago by Franchi Denis.
    Thread Starter Franchi Denis

    (@franchidesign)

    Here is the html code of the template:

    <?php
    /**
    * Template Name: Portfolio Standar
    * Template Post Type: page
    *
    * @author    Denis Franchi
    * @package   Willer
    * @version   1.0.0
    *
    */
    
    get_header();?>
    
    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        <?php  $portfolio = new WP_Query( array(
          'posts_per_page' => 3,
          'paged' => get_query_var( 'paged' )
        ) );
        
        if( $portfolio->have_posts() ) {
          while( $portfolio->have_posts() ) {
            
            $portfolio->the_post();
            $meta_value = get_post_meta( get_the_ID() , 'meta-select', false );
            
            ?>
            
            <div class="col-lg-4
            <?php if( !empty( $meta_value ) ) {
              print_r( $meta_value );
            }
            ?> col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?>
          </div>
          
          <?php
        }
        // Very Important
        wp_reset_postdata();
      }
      ?>
      
    </div>
    </div>
    
    <!-- Loader oder post -->
    
    <div class="container willer-load-more-posts">
      <?php
      $next_link = get_previous_posts_link(false);
      $prev_link = get_next_posts_link( false);
      if (get_previous_posts_link('Pagina precedente', $portfolio->max_num_pages )!=$next_link): ?>
      <button data-animation="animated fadeInRight" class="btn btn-1 btn-border-willer btn-1c">
        <?php previous_posts_link( 'Pagina successiva', $portfolio->max_num_pages );?>
      </button>
    <?php endif;
    if (get_next_posts_link('Pagina successiva', $portfolio->max_num_pages)!=$prev_link): ?>
    <button data-animation="animated fadeInRight" class="btn btn-1 btn-border-willer btn-1c">
      <?php next_posts_link( 'Pagina precedente', $portfolio->max_num_pages );?>
    </button>
    <?php endif; ?>
    </div>
    
    <?php get_footer(); ?>
    
    <?php
    /**
     * content-post-portfolio-all-standar.php
     *
     * @author    Denis Franchi
     * @package   Willer
     * @version   1.0.0
     */
    
    ?>
    
    <?php $willer_image_attributes =  wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'willer_big');?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
      <a class="willer-img-portfolio-all-standar" href="<?php the_permalink();?>" >
        <div class="inside">
          <div class="details">
            <div class="text">
              <h2><?php the_title();?></h2>
              <div class="wiler-divide-portfolio-page-text-about"></div>
            </div>
          </div>
          <div class="overlay"></div>
          <img src="<?php if ( $willer_image_attributes[0] ) :
            echo esc_url($willer_image_attributes[0]);
          else: echo esc_url(get_template_directory_uri()).'/images/willer-default.jpg'; endif; ?>"/>
        </div>
      </a>
    </article>
    

    This is saving code:

    /* ------------------------------------------------------------------------- *
    ##  1 Add meta box page Portfolio Standar */
    /* ------------------------------------------------------------------------- */
    
    function willer_custom_meta_portfolio_standar() {
    	add_meta_box( 'page-portfolio-standar-meta-box', __( 'Meta box Portfolio Standar', 'willer' ), 'willer_portfolio_standar_meta_callback', 'page' );
    }
    add_action( 'add_meta_boxes', 'willer_custom_meta_portfolio_standar' );
    
    /** Outputs the content of the meta box */
    
    function willer_portfolio_standar_meta_callback( $post ) {
    	wp_nonce_field( basename( __FILE__ ), 'willer_nonce' );
    	$wl_portfolio = get_post_meta( $post->ID );
    	?>
    
    	<div id="wl_template_page_portfolio_standar_wrapper">
    		<p>
    			<label for="meta-select" class="prfx-row-title"><?php _e( 'Example Select Input', 'prfx-textdomain' )?></label>
    			<select name="meta-select" id="meta-select">
    				<option value="select-one" <?php if ( isset ( $wl_portfolio['meta-select'] ) ) selected( $wl_portfolio['meta-select'][0], 'select-one' ); ?>><?php _e( 'One', 'prfx-textdomain' )?></option>';
    				<option value="select-two" <?php if ( isset ( $wl_portfolio['meta-select'] ) ) selected( $wl_portfolio['meta-select'][0], 'select-two' ); ?>><?php _e( 'Two', 'prfx-textdomain' )?></option>';
    			</select>
    		</p>
    	</div>
    	<?php
    }
    
    /** Saves the custom meta input */
    
    function willer_portfolio_standar_meta_save( $post_id ) {
    
    	// Checks save status
    	$is_autosave = wp_is_post_autosave( $post_id );
    	$is_revision = wp_is_post_revision( $post_id );
    	$is_valid_nonce = ( isset( $_POST[ 'willer_nonce' ] ) && wp_verify_nonce( $_POST[ 'willer_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
    
    	// Exits script depending on save status
    	if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
    		return;
    	}
    
    	// Checks for input and saves if needed
    	if( isset( $_POST[ 'meta-select' ] ) ) {
    		update_post_meta( $post_id, 'meta-select', $_POST[ 'meta-select' ] );
    	}
    
    }
    add_action( 'save_post', 'willer_portfolio_standar_meta_save' );
    

    I did the search in the DB as shown with post_ID 380 and meta_key met-select , the result is No rows.

    I have also disabled active plugins: Theme Sniffer,Contact Form 7 end WP ULike , but the result does not change.

    I put the code in the theme Twentyseventeen the result is always the same.
    Putting the code like this instead in Twentyseventeen

    <?php
    /**
    * Template Name: Portfolio Standar
    * Template Post Type: page
    *
    * @author    Denis Franchi
    * @package   Willer
    * @version   1.0.0
    *
    */
    
    get_header();?>
    
    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        <?php  $portfolio = new WP_Query( array(
          'posts_per_page' => 3,
          'paged' => get_query_var( 'paged' )
        ) );
    
        if( $portfolio->have_posts() ) {
          while( $portfolio->have_posts() ) {
    
            $portfolio->the_post();
    
            ?>
    
            <div class="col-lg-4
          <?php print_r( get_post_meta( 380, 'meta-select', false )); ?> col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?>
          </div>
    
          <?php
        }
        // Very Important
        wp_reset_postdata();
      }
      ?>
    
    </div>
    </div>
    
    <!-- Loader oder post -->
    
    <div class="container willer-load-more-posts">
      <?php
      $next_link = get_previous_posts_link(false);
      $prev_link = get_next_posts_link( false);
      if (get_previous_posts_link('Pagina precedente', $portfolio->max_num_pages )!=$next_link): ?>
      <button data-animation="animated fadeInRight" class="btn btn-1 btn-border-willer btn-1c">
        <?php previous_posts_link( 'Pagina successiva', $portfolio->max_num_pages );?>
      </button>
    <?php endif;
    if (get_next_posts_link('Pagina successiva', $portfolio->max_num_pages)!=$prev_link): ?>
    <button data-animation="animated fadeInRight" class="btn btn-1 btn-border-willer btn-1c">
      <?php next_posts_link( 'Pagina precedente', $portfolio->max_num_pages );?>
    </button>
    <?php endif; ?>
    </div>
    
    <?php get_footer(); ?>
    

    the result is this:

    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        
            <div class="col-lg-4
          Array
    (
    )
     col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
                  </div>
    
          
            <div class="col-lg-4
          Array
    (
    )
     col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
                  </div>
    
          
            <div class="col-lg-4
          Array
    (
    )
     col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
                  </div>
    
          
    </div>
    </div>
    

    I did another test, with the input option, post_get_meta it works well

    <?php
    /**
    * Template Name: Portfolio Standar
    * Template Post Type: page
    *
    * @author    Denis Franchi
    * @package   Willer
    * @version   1.0.0
    *
    */
    
    get_header();?>
    <?php $wl_breadcrumb_portfolio_standar = get_post_meta( get_the_ID(), 'willer_enable_breadcrumb_portfolio_standar', true );?>
    
    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        <?php  $portfolio = new WP_Query( array(
          'posts_per_page' => 3,
          'paged' => get_query_var( 'paged' )
        ) );
    
        if( $portfolio->have_posts() ) {
          while( $portfolio->have_posts() ) {
    
            $portfolio->the_post();
            $meta_value = get_post_meta( get_the_ID() , 'meta-select', false );
    
            ?>
    
            <div class="col-lg-4
            <?php if( !empty( $meta_value ) ) {
              print_r( $meta_value );
            }
            ?> col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?>
          </div>
          <!-- Function dinamic template enable Breadcrumb -->
          <?php if ( ! empty( $wl_breadcrumb_portfolio_standar ) ) : ?>
          <div class="container-fluid willer-container-breadcrumb">
            <div class="row">
              <div class="willer-img-breadcrumb-page breadcrumb-portfolio-standar">
                <?php willer_page_the_breadcrumb(); ?>
              </div>
            </div>
          </div>
          <!-- End Function dinamic template enable Breadcrumb -->
          <?php endif; ?>
    
          <?php
        }
        // Very Important
        wp_reset_postdata();
      }
      ?>
    
    </div>
    </div>
    
    <!-- Loader oder post -->
    
    <div class="container willer-load-more-posts">
    
      <?php
        $next_link = get_previous_posts_link(false);
        $prev_link = get_next_posts_link( false);
         if (get_previous_posts_link('Pagina precedente', $portfolio->max_num_pages )!=$next_link): ?>
         <button data-animation="animated fadeInRight" class="btn btn-1 btn-border-willer btn-1c">
         <?php previous_posts_link( 'Pagina successiva', $portfolio->max_num_pages );?>
         </button>
         <?php endif;
          if (get_next_posts_link('Pagina successiva', $portfolio->max_num_pages)!=$prev_link): ?>
         <button data-animation="animated fadeInRight" class="btn btn-1 btn-border-willer btn-1c">
         <?php next_posts_link( 'Pagina precedente', $portfolio->max_num_pages );?>
         </button>
        <?php endif; ?>
    </div>
    
    <?php get_footer(); ?>
    
    /* ------------------------------------------------------------------------- *
    ##  1 Add meta box page Portfolio Standar */
    /* ------------------------------------------------------------------------- */
    
    function willer_custom_meta_portfolio_standar() {
    	add_meta_box( 'page-portfolio-standar-meta-box', __( 'Meta box Portfolio Standar', 'willer' ), 'willer_portfolio_standar_meta_callback', 'page' );
    }
    add_action( 'add_meta_boxes', 'willer_custom_meta_portfolio_standar' );
    
    /** Outputs the content of the meta box */
    
    function willer_portfolio_standar_meta_callback( $post ) {
    	wp_nonce_field( basename( __FILE__ ), 'willer_nonce' );
    	$wl_portfolio_standar = get_post_meta( $post->ID );
    	$wl_portfolio = get_post_meta( $post->ID );
    	?>
    
    	<div id="wl_template_page_portfolio_standar_wrapper">
    		<p>
    			<span class="willer-title-meta-box"><?php esc_html_e( 'Enable breadcrumb', 'willer' )?></span>
    			<div class="willer-content-meta-box">
    				<label for="willer_enable_breadcrumb_portfolio_standar">
    					<input type="checkbox" name="willer_enable_breadcrumb_portfolio_standar" id="willer_enable_breadcrumb_portfolio_standar"
    					       value="yes" <?php if ( isset ( $wl_portfolio_standar['willer_enable_breadcrumb_portfolio_standar'] ) ) checked( $wl_portfolio_standar['willer_enable_breadcrumb_portfolio_standar'][0], 'yes' ); ?> />
    					<?php _e( 'Checkbox label', 'prfx-textdomain' )?>
    				</label>
    			</div>
    		</p>
    
    		<p>
    			<label for="meta-select" class="prfx-row-title"><?php _e( 'Example Select Input', 'prfx-textdomain' )?></label>
    			<select name="meta-select" id="meta-select">
    				<option value="select-one" <?php if ( isset ( $wl_portfolio['meta-select'] ) ) selected( $wl_portfolio['meta-select'][0], 'select-one' ); ?>><?php _e( 'One', 'prfx-textdomain' )?></option>';
    				<option value="select-two" <?php if ( isset ( $wl_portfolio['meta-select'] ) ) selected( $wl_portfolio['meta-select'][0], 'select-two' ); ?>><?php _e( 'Two', 'prfx-textdomain' )?></option>';
    			</select>
    		</p>
    	</div>
    	<?php
    }
    
    /** Saves the custom meta input */
    
    function willer_portfolio_standar_meta_save( $post_id ) {
    
    	// Checks save status
    	$is_autosave = wp_is_post_autosave( $post_id );
    	$is_revision = wp_is_post_revision( $post_id );
    	$is_valid_nonce = ( isset( $_POST[ 'willer_nonce' ] ) && wp_verify_nonce( $_POST[ 'willer_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
    
    	// Exits script depending on save status
    	if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
    		return;
    	}
    
    	// Checks for input and saves
    	if( isset( $_POST[ 'willer_enable_breadcrumb_portfolio_standar' ] ) ) {
    		update_post_meta( $post_id, 'willer_enable_breadcrumb_portfolio_standar', 'yes' );
    	} else {
    		update_post_meta( $post_id, 'willer_enable_breadcrumb_portfolio_standar', '' );
    	}
    
    	// Checks for input and saves if needed
    	if( isset( $_POST[ 'meta-select' ] ) ) {
    		update_post_meta( $post_id, 'meta-select', $_POST[ 'meta-select' ] );
    	}
    
    }
    add_action( 'save_post', 'willer_portfolio_standar_meta_save' );
    
    Thread Starter Franchi Denis

    (@franchidesign)

    The code saving values it’s correct because out of the loop function very well.
    The code values it’s an imput select(select-one and select-two).
    The itself function used in
    `<div class=”container”>
    <div class=”row”>
    <!– Query Post Portfolio–>`
    In
    container has worked good.

    Thread Starter Franchi Denis

    (@franchidesign)

    I modified as described:

    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        <?php  $portfolio = new WP_Query( array(
          'posts_per_page' => 3,
          'paged' => $paged,
        ) );
    
        if( $portfolio->have_posts() ) {
          while( $portfolio->have_posts() ) {
    
            $portfolio->the_post();
            $meta_value = get_post_meta( get_the_ID() , 'meta-select', false );
    
            ?>
    
            <div class="col-lg-4
            <?php if( !empty( $meta_value ) ) {
              print_r( $meta_value );
            }
            ?> col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?>
          </div>
    
          <?php
        }
        // Very Important
        wp_reset_postdata();
      }
      ?>
    
    </div>
    </div>

    but it does not work.
    This is what he prints

    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        
            <div class="col-lg-4
             col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            
    
    <article id="post-382" class="post-382 post type-post status-publish format-standard has-post-thumbnail hentry category-uncategorized odd">
      <a class="willer-img-portfolio-all-standar" href="http://willer.local/project-standar/" >
        <div class="inside">
          <div class="details">
            <div class="text">
              <h2>Project standar</h2>
              <div class="wiler-divide-portfolio-page-text-about"></div>
            </div>
          </div>
          <div class="overlay"></div>
          <img src="http://willer.local/wp-content/uploads/2018/09/aboutme.jpg"/>
        </div>
      </a>
    </article>
          </div>
    
          
            <div class="col-lg-4
             col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            
    
    <article id="post-380" class="post-380 post type-post status-publish format-standard has-post-thumbnail hentry category-uncategorized even">
      <a class="willer-img-portfolio-all-standar" href="http://willer.local/project-1/" >
        <div class="inside">
          <div class="details">
            <div class="text">
              <h2>Project 1</h2>
              <div class="wiler-divide-portfolio-page-text-about"></div>
            </div>
          </div>
          <div class="overlay"></div>
          <img src="http://willer.local/wp-content/uploads/2018/09/test44-1400x800.jpg"/>
        </div>
      </a>
    </article>
          </div>
    
          
            <div class="col-lg-4
            Array
    (
        [0] => select-one
    )
     col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            
    
    <article id="post-353" class="post-353 post type-post status-publish format-standard has-post-thumbnail hentry category-uncategorized odd">
      <a class="willer-img-portfolio-all-standar" href="http://willer.local/test/" >
        <div class="inside">
          <div class="details">
            <div class="text">
              <h2>test</h2>
              <div class="wiler-divide-portfolio-page-text-about"></div>
            </div>
          </div>
          <div class="overlay"></div>
          <img src="http://willer.local/wp-content/uploads/2018/09/aboutme.jpg"/>
        </div>
      </a>
    </article>
          </div>
    
          
    </div>
    </div>
    Thread Starter Franchi Denis

    (@franchidesign)

    I did the checks and everything seems ok.
    get_the_ID() out of the loop works perfectly, and the value is saved correctly.
    The ID is printed in a post with the correct call, while in the other posts with the value 1.

    <div class="col-lg-4 select-one col-xs-12 aos-init aos-animate" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            
    
    <article id="post-353" class="post-353 post type-post status-publish format-standard has-post-thumbnail hentry category-uncategorized even">
      <a class="willer-img-portfolio-all-standar" href="http://willer.local/test/">
        <div class="inside">
          <div class="details">
            <div class="text">
              <h2>test</h2>
              <div class="wiler-divide-portfolio-page-text-about"></div>
            </div>
          </div>
          <div class="overlay"></div>
          <img src="http://willer.local/wp-content/uploads/2018/09/aboutme.jpg">
        </div>
      </a>
    </article>
          </div>
    <div class="col-lg-4 1 col-xs-12 aos-init aos-animate" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            
    
    <article id="post-235" class="post-235 post type-post status-publish format-standard has-post-thumbnail hentry category-vcard odd">
      <a class="willer-img-portfolio-all-standar" href="http://willer.local/v-card/">
        <div class="inside">
          <div class="details">
            <div class="text">
              <h2>V-Card</h2>
              <div class="wiler-divide-portfolio-page-text-about"></div>
            </div>
          </div>
          <div class="overlay"></div>
          <img src="http://willer.local/wp-content/uploads/2018/09/actrat.jpg">
        </div>
      </a>
    </article>
          </div>

    Value ( select-one ) it’s correct.
    Value (1) it’s incorrect.

    • This reply was modified 7 years, 9 months ago by Franchi Denis.
    Thread Starter Franchi Denis

    (@franchidesign)

    Hello, thanks for a quick reply.
    I tried to do as described,this works, but in this way does not print the posts, but only prints the title and the image of the page “Portfolio” in which I find myself.

    
    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        <?php  $portfolio = new WP_Query( array(
          'posts_per_page' => 9,
          'paged' => $paged,
        ) );
        
        if( $portfolio->have_posts() ) {
          while( $portfolio->have_posts() ) {
            
            $portfolio->the_post();
            $meta_value = get_post_meta( get_the_ID() , 'meta-select', true );
            
          }
          
          // Very Important
          wp_reset_postdata();
        }
        ?>
        <div class="col-lg-4 <?php
        // Retrieves the stored value from the database
        $meta_value = get_post_meta( get_the_ID() , 'meta-select', true );
        // Checks and displays the retrieved value
        if( !empty( $meta_value ) ) {
          echo $meta_value;
        }
        ?> col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
        <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?>
      </div>
      
    </div>
    </div>
    

    If instead edited like this:

    <div class="container">
      <div class="row">
        <!-- Query Post Portfolio-->
        <?php  $portfolio = new WP_Query( array(
          'posts_per_page' => 9,
          'paged' => $paged,
        ) );
        
        if( $portfolio->have_posts() ) {
          while( $portfolio->have_posts() ) {
            
            $portfolio->the_post();
            $meta_value = get_post_meta( get_the_ID() , 'meta-select', true );
            
            ?>
            
            <div class="col-lg-4
            <?php if( !empty( $meta_value ) ) {
              echo $meta_value;
            }
            ?> col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic">
            <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?>
          </div>
          
          <?php
        }
        // Very Important
        wp_reset_postdata();
      }
      ?>
      
    </div>
    </div>
    

    print the posts but the get_post_meta does not work.

    this is the meta box code

    /* ------------------------------------------------------------------------- *
    ##  1 Add meta box page Portfolio Standar */
    /* ------------------------------------------------------------------------- */
    
    function willer_custom_meta_portfolio_standar() {
    	add_meta_box( 'page-portfolio-standar-meta-box', __( 'Meta box Portfolio Standar', 'willer' ), 'willer_portfolio_standar_meta_callback', 'page' );
    }
    add_action( 'add_meta_boxes', 'willer_custom_meta_portfolio_standar' );
    
    /** Outputs the content of the meta box */
    
    function willer_portfolio_standar_meta_callback( $post ) {
    	wp_nonce_field( basename( __FILE__ ), 'willer_nonce' );
    	$wl_portfolio_standar = get_post_meta( $post->ID );
    	$wl_portfolio = get_post_meta( $post->ID );
    	?>
    
    	<div id="wl_template_page_portfolio_standar_wrapper">
    		<p>
    			<span class="willer-title-meta-box"><?php esc_html_e( 'Enable breadcrumb', 'willer' )?></span>
    			<div class="willer-content-meta-box">
    				<label for="willer_enable_breadcrumb_portfolio_standar">
    					<input type="checkbox" name="willer_enable_breadcrumb_portfolio_standar" id="willer_enable_breadcrumb_portfolio_standar"
    					       value="yes" <?php if ( isset ( $wl_portfolio_standar['willer_enable_breadcrumb_portfolio_standar'] ) ) checked( $wl_portfolio_standar['willer_enable_breadcrumb_portfolio_standar'][0], 'yes' ); ?> />
    					<?php _e( 'Checkbox label', 'prfx-textdomain' )?>
    				</label>
    			</div>
    		</p>
    
    		<p>
    			<label for="meta-select" class="prfx-row-title"><?php _e( 'Example Select Input', 'prfx-textdomain' )?></label>
    			<select name="meta-select" id="meta-select">
    				<option value="select-one" <?php if ( isset ( $wl_portfolio['meta-select'] ) ) selected( $wl_portfolio['meta-select'][0], 'select-one' ); ?>><?php _e( 'One', 'prfx-textdomain' )?></option>';
    				<option value="select-two" <?php if ( isset ( $wl_portfolio['meta-select'] ) ) selected( $wl_portfolio['meta-select'][0], 'select-two' ); ?>><?php _e( 'Two', 'prfx-textdomain' )?></option>';
    			</select>
    		</p>
    	</div>
    	<?php
    }
    
    /** Saves the custom meta input */
    
    function willer_portfolio_standar_meta_save( $post_id ) {
    
    	// Checks save status
    	$is_autosave = wp_is_post_autosave( $post_id );
    	$is_revision = wp_is_post_revision( $post_id );
    	$is_valid_nonce = ( isset( $_POST[ 'willer_nonce' ] ) && wp_verify_nonce( $_POST[ 'willer_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
    
    	// Exits script depending on save status
    	if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
    		return;
    	}
    
    	// Checks for input and saves
    	if( isset( $_POST[ 'willer_enable_breadcrumb_portfolio_standar' ] ) ) {
    		update_post_meta( $post_id, 'willer_enable_breadcrumb_portfolio_standar', 'yes' );
    	} else {
    		update_post_meta( $post_id, 'willer_enable_breadcrumb_portfolio_standar', '' );
    	}
    
    	// Checks for input and saves if needed
    	if( isset( $_POST[ 'meta-select' ] ) ) {
    		update_post_meta( $post_id, 'meta-select', $_POST[ 'meta-select' ] );
    	}
    
    }
    add_action( 'save_post', 'willer_portfolio_standar_meta_save' );
    
Viewing 15 replies - 16 through 30 (of 32 total)