Combine multiple separate lists into one

You can use a multidimensional array to get this format. Please see the example given below: $terms = get_terms( array( ‘taxonomy’ => “issueCompanion”, ‘hide_empty’ => false, ‘fields’=>’all’ ) ) $multi_arr = array(); foreach($terms as $term){ $year = get_field(‘published_year’, $term->term_id); $multi_arr[$year][] = $term->name; } When you print this $multi_arr you will get the format you want. … Read more

Display current user metadata on WordPress page

You can try below snippet of code. i have develop shortcode you can take reference from it. function current_user_data_func( $atts ) { extract( shortcode_atts( array( ‘metakey’ => ”, ‘user_field’ => ”, ), $atts) ); ob_start(); if(is_user_logged_in()) { $current_user = wp_get_current_user(); $c_user_id = $current_user->ID; if(!empty($metakey)) { $value = get_user_meta( $c_user_id, $metakey, true); echo $value; } if(!empty($user_field)) … Read more

Add a default style if no Featured image is selected

You can test if the $thumb has any contents and then apply a class to the featured image block that you can use to hide the container. <?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘full’ ); ?> <div id=”post” class=”featured-image <?php echo empty($thumb) ? ‘no-featured-image-class’ : ”; ?>” style=”background-image: url(‘<?php echo $thumb[‘0′]; ?>’)”>

ACF under category name in shop page [closed]

If i understand you correctly here you want to display some text under each of the category titles on your shop page. Instead of editing the template i would suggest using a hook. To do this you should move your code into functions.php. The complete code would look something like this: add_action(‘woocommerce_after_subcategory_title’, ‘wpse_add_custom_text_under_category_title’, 10); function … Read more

Replace header with large image on home page only, using Genesis child theme

Well I got it working with a different approach but a good answer that provides insight why the approach in my question didn’t work will be accepted as the answer. I put this in functions.php for the child theme: add_action( ‘genesis_before_header’, ‘bob_gray_image’, 10 ); function bob_gray_image() { if ( is_front_page() ) { echo(‘<div class=”bobgrayimage”><img src=”https://wordpress.stackexchange.com/images/robert-c-gray-banner-maskbob-sharpen.jpg”></div>’); … Read more

How to change the value of a variable using input field?

Please try below snippet of code. HTML : <input name=”getUser” id=”getUser” value=””/> <div id=”user_data”></div> JS (js/my-ajax-script.js) jQuery(document).ready(function($){ $(‘#getUser’).keyup(function(e) { var user_id = e.target.value; console.log(user_id); $.ajax({ url:my_ajax_object.ajaxurl, #add here your ajax url type:’POST’, data:’action=get_this_user_data&user_id=’+user_id , success:function(results) { jQuery(‘#user_data’).html(results); } }); }); }); Ajax (add in functions.php) function my_enqueue() { wp_enqueue_script( ‘ajax-script’, get_template_directory_uri() . ‘/js/my-ajax-script.js’, array(‘jquery’) ); … Read more