php have code skip button click to next step and go straight to the next step automatically - php

I am editing a template that currently has two steps. I want to make it automatically go to step two upon loading, or skip step 1 altogether. I have tried using the headerfunction but that didnt seem to get me what I needed.
At the bottom of the page on step 1 there is a "create new product button" that is the link I am trying to skip to without having to click the button.
Here is the code:
<div class="col-md-12 add-product-outer-wrapper">
<div class="select-product-cat-wrapper">
<?php $is_new_listing = isset($_REQUEST['new_listing']) ? true : false;
$is_cats_hier = isset($_REQUEST['cats_hier']) ? true : false;
if( ( $is_new_listing && $is_cats_hier ) || !get_wcmp_vendor_settings('is_singleproductmultiseller', 'general') == 'Enable' ) {
?>
<!-- New product list categories hierarchically -->
<div class="select-cat-step-wrapper">
<div class="cat-step1" >
<div class="panel panel-default pannel-outer-heading mt-0">
<div class="panel-heading d-flex">
<h1><span class="primary-color"><span><?php _e( 'Step 1 of', 'dc-woocommerce-multi-vendor' );?></span> <?php _e( '2:', 'dc-woocommerce-multi-vendor' );?></span> <?php _e('Select a product category', 'dc-woocommerce-multi-vendor'); ?></h1>
<h3><?php _e('Once a category is assigned to a product, it cannot be altered.', 'dc-woocommerce-multi-vendor'); ?></h3>
</div>
<div class="panel-body panel-content-padding form-horizontal breadcrumb-panel">
<?php echo $url; ?>
</div>
</div>
<div class="panel panel-default pannel-outer-heading wcmp-categories-level-panel has-scroller">
<div class="cat-column-scroller cat-left-scroller"><i class="wcmp-font ico-left-arrow-icon"></i></div>
<div class="form-horizontal cat-list-holder">
<div class="wcmp-product-categories-wrap cat-column-wrapper">
<div class="wcmp-product-cat-level 1-level-cat cat-column" data-level="1" data-mcs-theme="dark">
<ul class="wcmp-product-categories 1-level" data-cat-level="1">
<?php echo wcmp_list_categories( apply_filters( 'wcmp_vendor_product_classify_1_level_categories', array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'html_list' => true,
'cat_link' => 'javascript:void(0)',
) ) ); ?>
</ul>
</div>
</div>
</div>
<div class="cat-column-scroller cat-right-scroller"><i class="wcmp-font ico-right-arrow-icon"></i></div>
</div>
</div>
</div>
<?php }else{ ?>
<!-- List a product by name or gtin -->
<div class="cat-intro">
<div class="panel panel-default pannel-outer-heading mt-0">
<div class="panel-body panel-content-padding form-horizontal text-center">
<img src="<?php echo $WCMp->plugin_url.'assets/images/add-product-graphic.png'; ?>" alt="">
<h1 class="heading-underline"><?php _e('List a New Product', 'dc-woocommerce-multi-vendor'); ?></h1>
<div class="serach-product-cat-wrapper">
<h2><?php// _e('Search from our existing Product Catalog', 'dc-woocommerce-multi-vendor'); ?></h2>
<?php
if (get_option('permalink_structure')) {
$category_url = '?new_listing=1&cats_hier=1';
} else {
$category_url = wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_add_product_endpoint', 'vendor', 'general', 'add-product' ) ) . '&new_listing=1&cats_hier=1';
}
$url = ( get_wcmp_vendor_settings('is_disable_marketplace_plisting', 'general') == 'Enable' ) ? esc_url(wcmp_get_vendor_dashboard_endpoint_url(get_wcmp_vendor_settings('wcmp_edit_product_endpoint', 'vendor', 'general', 'edit-product'))) : $category_url; ?>
<p><?php //_e('Not in the catalog?', 'dc-woocommerce-multi-vendor'); ?> <?php _e('Create a new product', 'dc-woocommerce-multi-vendor'); ?> <i class="wcmp-font ico-right-arrow-icon"></i></p>
</div>
</div>
</div>
<!-- End List a product by name or gtin -->
<?php } ?>
<div class="clearfix"></div>
</div>
</div>

Related

Dynamically change (or user change) the number of columns in Wordpress

I'm trying to display a custom post type ' products' here:
The issue is, in the close future they will have 7 products which will leave one on a row on its own.
Is there a way I can alter the number of columns dynamically, So if there are 6 and under product it displays the posts I 3 columns, but if there are 7 items, it will display the posts section in 4 columns etc etc...
Or, is there a way I can allow the user to choose how many columns it displays in manually from the backend? I guess using something like Advanced Custom fields.
Ill be using a bootstrap based grid with a layout like this:
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
</div>
</div>
so if either needs to change this structure dynamically based on the number of posts OR based on the number a user selects from a dropdown in the backend, to:
<div class="container">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
</div>
</div>
Can anyone point me in the right direction to achieve this? I'm wondering if I'm overthinking it or indeed under-thinking it!
Thanks so much for looking!
PS - Heres what's I'm trying currently but it's not working...
<div class="container-flex our-products-strip">
<div class="lines-background-overlay" style="background-image: url(<?php bloginfo('stylesheet_directory'); ?>/images/background-stripes2.png);"></div>
<div class="container strip-padding">
<h2>Our Products</h2>
<hr class="hr-blue-more-bottom-space">
<div class="row justify-content-center">
<?php
$args = array(
'post_type' => 'products',
'posts_per_page' => 9999,
'orderby' => 'none'
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php $data = new WP_Query(array( 'post_type' => 'products' ));?>
<?php if(count($data) < 6 ){?>
<div class="col-md-6 col-lg-4 products-item-outer" style="--product-color: <?php the_field('product_colour'); ?>;">
<div class="col-12 products-item-inner">
<a href="<?php the_permalink(); ?>">
<div class="click-overlay"></div>
</a>
<div class="logo">
<?php
$image = get_field('logo_light');
if( !empty( $image ) ): ?>
<img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
<?php endif; ?>
</div>
<div class="excerpt"><p><?php the_field('excerpt_text'); ?></p></div>
<div class="read-more-link">Read More<span class="arrow-right"></span></div>
</div>
</div>
<?php }
else{ ?>
<div class="col-md-3 products-item-outer" style="--product-color: <?php the_field('product_colour'); ?>;">
<div class="col-12 products-item-inner">
<a href="<?php the_permalink(); ?>">
<div class="click-overlay"></div>
</a>
<div class="logo">
<?php
$image = get_field('logo_light');
if( !empty( $image ) ): ?>
<img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
<?php endif; ?>
</div>
<div class="excerpt"><p><?php the_field('excerpt_text'); ?></p></div>
<div class="read-more-link">Read More<span class="arrow-right"></span></div>
</div>
</div>
<?php } ?>
<?php endwhile; wp_reset_postdata(); endif; ?>
</div>
</div>
</div>
</div>
If you are using php then definitely you can put if condition to perform the check
below is the example
<?php if(count($data) <= 6){?>
<div class="container">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
</div>
</div>
<?php }
else{ ?>
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
</div>
</div>
<? } >

get woocommerce shop page post thumbnail

I have a problem with woocommerce. I'm using the woocommerce_before_main_content hook to add a .jumbotron page cover. I was able to display the content like page title and categories that needs to appear on the background image, but the image that is displayed is the worng one, I don't know why but wordpress will show the first product image thumbnail and the image I've selected as featured inside the shop page of woocommerce is different. Is there a solution?
I'm using this code:
function btheme_woocommerce_before_main_content()
{
if( has_post_thumbnail() ):
?>
<div class="jumbotron jumbotron-fluid shop-page-cover" style="background-image:url('<?php echo the_post_thumbnail_url(); ?>');">
<!-- <div class="parallax" data-parallax-image></div> -->
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 text-center">
<h1 class=""><?php woocommerce_page_title(); ?></h1>
<?php $categories = get_terms( array('taxonomy' => 'product_cat') ); ?>
<?php foreach( $categories as $category ): ?>
<h4 class="category-name d-inline"><?php echo $category->name; ?></h4>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="container-fluid content-wrapper" id="uptheme-woocommece-wrapper">
<?php
}
add_action( 'woocommerce_before_main_content', 'btheme_woocommerce_before_main_content', 10 );
first you need to get post thumbnail by id
<?php
$shop_page_id = wc_get_page_id('shop');
function btheme_woocommerce_before_main_content()
{
if( has_post_thumbnail($shop_page_id) ):
?>
<div class="jumbotron jumbotron-fluid shop-page-cover" style="background-image:url('<?php echo get_the_post_thumbnail_url($shop_page_id,'full'); ?>');">
<!-- <div class="parallax" data-parallax-image></div> -->
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 text-center">
<h1 class=""><?php woocommerce_page_title(); ?></h1>
<?php $categories = get_terms( array('taxonomy' => 'product_cat') ); ?>
<?php foreach( $categories as $category ): ?>
<h4 class="category-name d-inline"><?php echo $category->name; ?></h4>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="container-fluid content-wrapper" id="uptheme-woocommece-wrapper">
<?php
}
add_action( 'woocommerce_before_main_content', 'btheme_woocommerce_before_main_content', 99 );

Wordpress older post page error

I have a problem with a custom wordpress template.
I've made a categories page. Works fine on the firs view.
But when I make click on 2nd page for older posts, the browser shows me a 404 error.
I think my query needs something more, but I don't know what is or if this is the problem.
Can somebody help, please?
This is my code:
<?php
/**
* The template for displaying Category pages
*/
?>
<?php get_header(); ?>
<?php get_template_part( 'partials/linea-content', 'page' ); ?>
<div class="index categories">
<div class="col-xs-12 pre-content">
<div class="container">
<?php //Para añadir contenido se interesa ?>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12 categories-title">
<h2>Categoria: <span><?php echo get_category(get_query_var('cat'))->name; ?></span></h2>
</div>
<div id="posts" class="col-xs-12 col-sm-9">
<?php
// set the "paged" parameter (use 'page' if the query is on a static front page)
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// Cambiamos los argumentos para buscar desde la última
$args = array(
'posts_per_page' => 2,
'orderby' => 'date',
'order' => ASC,
'category__in' => get_category(get_query_var('cat'))->cat_ID,
'paged' => $paged
);
// '&orderby=date&order=ASC&category=' . get_category(get_query_var('cat'))->cat_ID;
// volvemos a crear la consulta principal
$aux = query_posts( $args );
$cont_items = 1;
?>
<?php if ( have_posts() ) : ?>
<div class="row items-row">
<div class="col-xs-12">
<?php while ( have_posts() ) : the_post(); ?>
<!-- post -->
<div id="post-id-<?php echo $post->ID; ?>" class="item col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 text-center item-content">
<span class="meta-category">
<span class="meta-category-inner">
<?php
$cat = get_the_category($post->ID);
?>
<?php echo $cat[0]->name; ?>
</span>
</span>
<?php
global $wpdb;
$ppbv_tablename = $wpdb->prefix . 'popular_by_views';
$currentRow = $wpdb->get_row("SELECT * FROM {$ppbv_tablename} WHERE post_id = {$post->ID}");
$curView = 0;
if(isset($currentRow))
{
$curView = $currentRow->views;
}
?>
<div class="item-title-content">
<a href="<?php the_permalink(); ?>" title="Popsicase">
<h2 class="item-title col-xs-10 col-xs-offset-1"><?php the_title(); ?></h2>
</a>
</div>
<p class="date-cat">
<small class="col-xs-12">
<i class="fa fa-link"></i> <strong><?php the_author(); ?></strong> | <span><i class="fa fa-calendar"></i> <?php echo get_the_date();?> | <i class="fa fa-eye"></i> <?php echo $curView; ?></span>
</small>
</p>
<?php
$img_url = get_template_directory_uri() . '/assets/img/podcast.jpg';
if (get_the_post_thumbnail())
{
$img_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
}
?>
<a href="<?php the_permalink(); ?>" title="Popsicase">
<div class="item-thumbnail" style="background:url(<?php echo $img_url; ?>) no-repeat center center;">
</div>
</a>
<div class="row">
<div class="col-xs-6 text-right">
<?php /*<span class="comment"> Comentarios: <?php comments_number( '0','1','%'); ?></span>*/ ?>
</div>
</div>
<div class="item-excerpt text-left">
<div class="col-xs-12">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
</div>
<?php if ($cont_items % 2 == 0) : ?>
</div>
</div>
<div class="row items-row">
<div class="col-xs-12">
<?php
endif;
$cont_items++;
?>
<?php endwhile; ?>
</div>
</div>
<!-- End of the main loop -->
<!-- Add the pagination functions here. -->
<?php
the_posts_pagination( array(
'mid_size' => 4,
'prev_text' => __( 'Artículos antiguos', 'textdomain' ),
'next_text' => __( 'Artículos nuevos', 'textdomain' ),
) );
?>
<?php /*
<div class="nav-previous alignleft"><?php next_posts_link( 'Artículos antiguos' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Artículos nuevos' ); ?></div>
*/ ?>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
<div class="hidden-xs col-sm-3 sidebar">
<div class="row">
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('main-sidebar')) : ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="col-xs-12 pos-content">
<div class="container">
<?php //Para añadir contenido se interesa ?>
</div>
</div>
<div class="clearfix"></div>
</div>

How can I random two fields using get_field?

In the code bellow Im displaying one Case using get_field(); on my startpage.
Know I wanna be able to random two fields(), using get_field('promoted_case') and get_field('promoted_case_two'); on the startpage.
When a person updates the webpage Its supposed to random the two fields...
How can I do that in my code?
<?php if ( $case = get_field( 'promoted_case') ) : ?>
<?php $link = get_permalink( $case->ID ); ?>
<section class="content row">
<header class="dotted">
<h2 class="centered uc feat-case-header"><?php _e( 'Featured case', 'vvt' ) ?></h2>
</header>
<article class="promoted_case">
<div class="row case-header">
<div class="twelve columns">
<h2 class="single-case-header"><?php echo esc_html( $case->post_title ); ?></h2>
</div>
</div>
<div class="row case-content">
<div class="columns six push_six">
<div class="frontpage_case_image">
<?php vvt_post_thumbnail( 'contact_images', $case->ID ); ?>
</div>
</div>
<div class="columns six pull_six entry-content">
<?php echo vvt_trim_words( $case->post_content ); ?>
<div class="frontpage_case_btn">
<a class="button" href="<?php echo home_url( '/cases/' ); ?>"><?php _e( 'Show all Cases', 'vvt' ); ?> <i class="icon-arrow-right"></i></a>
</div>
</div>
</div>
</article>
</section>
<?php endif; ?>
$fields = array('promoted_case', 'promoted_case_two');
$field = $fields[rand(0, count($fields) - 1)];
if ( $case = get_field( $field) )

Why custom post is not displaying according to template?

I am using crowdfunding by astoundify to ceate custom post type download(which is campaign actually). I have created a signle-download.php page as a template but post pages do not seem to use this template. Is there anything else I have to do?
code for single-download.php
<?php
global $wp_embed;
get_header();
?>
<div class="bigcontainer4">
<div class="container">
<div id="content">
<div class="clearfix">
<?php while ( have_posts() ) : the_post(); $campaign = new ATCF_Campaign( $post->ID ); ?>
<div class="project_content_line">
<div class="blog_post">
<div class="project_image_bg">
<div class="project_image">
<?php if ( $campaign->video() ) : ?>
<div class="project_video">
<div class="project_videobox">
<?php echo $wp_embed->run_shortcode( '[embed]' . $campaign->video() . '[/embed]' ); ?>
</div>
</div>
<?php else :
the_post_thumbnail('blog-single-image');
endif; ?>
</div>
<h1>
<?php the_title() ;?>
</h1>
</div>
</div>
<div class="blog_sidebar">
<div class="project_sb_date">
<?php printf( __( '%s'), get_the_date('') ); ?>
-
<?php printf( __( '%s'), $campaign->end_date('') ); ?></div>
<div class="project_sb_date_rem">
<?php echo $campaign->
days_remaining(); ?>
<?php echo _n( $campaign->days_remaining(), 'day left', 'days left' ); ?></div>
<div class="project_small_excerpt">
<?php //echo excerpt(26); ?>
<div class="project_list_box_loader">
<div class="project_list_box_loaderbar">
<span style="width: <?php echo $campaign->percent_completed(); ?>"></span>
</div>
</div>
</div>
<div class="project_money_data">
<div class="project_money_data1">
<p>
<?php echo $campaign->current_amount(); ?></p>
<span>Raised</span>
</div>
<div class="project_money_data2">
<p></p>
<span>
of
<?php printf( __( '%s'), $campaign->goal() ); ?></span>
</div>
<?php if ( $campaign->is_active() )
echo edd_get_purchase_link( array(
'download_id' => $post->ID,
'class' => '',
'price' => false,
'text' => __( 'Contribute Now', 'fundler' )
) );
?>
</div>
</div>
<div class="project_content_line">
<div class="blog_post">
<div class="project_content">
<?php the_content(); ?>
<div class="project_content_updates">
<div class="project_sb_title">
<p>Latest</p>
<span>Updates</span>
</div>
<?php echo $campaign->updates() ?>
</div>
<?php comments_template(); ?>
</div>
</div>
<div class="blog_sidebar">
<div class="project_author_box">
<div class="project_sb_title">
<p>About</p>
<span>The Author</span>
</div>
<div class="project_author_image">
<?php
$author_email = get_the_author_meta('email');
echo get_avatar($author_email, '512');
?>
<div class="project_author_image_data">
<p>
<?php if ( '' != $campaign->author() ) :
printf( __( '%s', 'fundler' ), esc_attr( $campaign->author() ) );
endif; ?>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php get_footer(); ?>
According to Wordpress documentation:
WordPress looks for template files with specific names in the current
Theme's directory and uses the first matching template file listed
under the appropriate query section below.
So, I guess, you have another template matching condition. And wordpress uses it to display your page.
Added from comment: May be you are using just another theme, not the one, your file resides in?

Categories