If Custom Taxonomy

get_the_term_list() returns a string of HTML for the list of taxonomy terms on the given post. Without giving values in the optional arguments it would look like this: <a href=”http://example.com/type/roast/” rel=”tag”>Roast</a> <a href=”http://example.com/type/type2/” rel=”tag”>Type 2</a> So $type == ‘roast’ would not be true because the value isn’t anything close to ‘roast’. Even if it returned … Read more

Get author Meta for particular user inside the loop

The function get_the_author_meta(‘ID’) will return the ID of the author for the current post. That means this line should work. get_avatar( get_the_author_meta( ‘ID’ ), 120); This will not work get_avatar( get_the_author_meta( ‘4’ ), 120); Because you are trying to get a property named ‘4’ inside the user object and that property doesn’t exist. If you … Read more

Custom loop not working

Try this: $args = array( ‘post_type’=> ‘televisie’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 5, ‘meta_key’ => ‘layout_meta_box’, ‘meta_value’ => ‘synopsis’, ); A helpful article too: https://css-tricks.com/snippets/wordpress/custom-loop-based-on-custom-fields/

Display single category name in woocommerce loop

<?php remove_action(‘woocommerce_shop_loop_item_title’, ‘woocommerce_template_loop_product_title’, 10); function loop_title() { global $post;?> <div class=”col-xl-3 col-md-3 col-sm-3″> <h3><a href=”https://wordpress.stackexchange.com/questions/304779/<?php the_permalink(); ?>” class=”feed-item-baslik”><?php the_title(); ?></a></h3> <?php $terms = get_the_terms( $post->ID, ‘product_cat’ ); if ( $terms && ! is_wp_error( $terms ) ) : if ( ! empty( $terms ) ) { echo $terms[0]->name; }?> <?php endif;?> </div> <?php } add_action(‘woocommerce_shop_loop_item_title’, ‘loop_title’, … Read more

Custon Content within WordPress Loop

You can use current_post field of WP_Query to check inside the loop, or you can break the loop in two loops. Here are code samples: <?php $services_loop = new WP_Query( array( ‘post_type’ => ‘service’, ‘posts_per_page’ => -1 ) ); while ( $services_loop->have_posts() ) : $services_loop->the_post(); ?> <section class=”single-service”> <div class=”container”> <div class=”row”> <div class=”col-md-6″> <?php … Read more

How to get post ID in a Page?

You should not use globals directly. There are some nice wrapper functions in the WordPress API. If you want to retrieve the ID of the current post or page just use get_the_ID(). Without any test … you could write the functionality in this way: $file_id = get_post_meta( get_the_ID(), ‘sound_s’, true ); $file_url = wp_get_attachment_url( $file_id … Read more

The Loop not looping?

I’m following your initial question. In your backend, create a page with the title Test 1, which should result in the page slug test-1. In your child theme folder, create a page template, using the filename page-test-1.php. WordPress will be loading this template, following this pattern: page-$slug.php. For more details, see here: https://developer.wordpress.org/files/2014/10/wp-hierarchy.png. In your … Read more