I have 2 post types i need to show the post type contents in 2 select boxes [closed]

Below Code will generate Select box of post type “resources” change this value as per your post type. <select name=”page_id” id=”page_id” class=”archive-dropdown” onchange=”document.location.href=this.options[this.selectedIndex].value;”> <option value=””>Select Resource Post</option> <?php global $post; $args = array( ‘numberposts’ => -1,’post_type’=>’resources’); $posts = get_posts($args); foreach( $posts as $post ) : setup_postdata($post); ?> <option value=”<? echo get_permalink($post->ID); ?>”><?php the_title(); ?></option> <?php … Read more

WordPress select field – show current value?

By referencing to the source code, this function supports an argument called value which you can pass one of the keys inside the options array like this: function woo_add_spin() { woocommerce_wp_select([ ‘id’ => ‘_select_nf’, ‘label’ => __( ‘Select #spins: ‘, ‘woocommerce’ ), ‘selected’ => true, ‘value’ => ’24’, ‘options’ => [ ’24’ => __( ’24’, … Read more

Retain select value in select box

If I have understood correctly, you could use get_the_ID() and compare the value with get_queried_object_id() to archive this: $args = array( ‘post_type’=> ‘portfolio’, ‘posts_per_page’ =>100, ‘offset’=> 0 ); $myposts = get_posts( $args ); $current_id = get_queried_object_id(); foreach ( $myposts as $post ) { setup_postdata( $post ); printf( ‘<option%s>%s</option>’, ( $current_id == get_the_ID() ) ? ‘ … Read more

how to save selection meta data in user profile on frontend

Ahh it turns out it wasn’t able to stay selected because I was using the “strtolower” function to remove capital letters. Which in turn caused there to be a mismatch between the selected value and the saved value in the database. add_action( ‘show_user_profile’, ‘product_selection_field’, 3 ); add_action( ‘edit_user_profile’, ‘product_selection_field’, 3 ); function product_selection_field( $user ) … Read more

Select query for a login

You can use wp_signon function Here is an example $creds = array(); $creds[‘user_login’] = ‘example’; $creds[‘user_password’] = ‘plaintextpw’; $creds[‘remember’] = true; $user = wp_signon( $creds, false ); if ( is_wp_error($user) ) echo $user->get_error_message();

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)