Adding an IF ELSE to a function

You can write this code like below- <?php $element = get_queried_object_id(); if (!empty($element)) { $terms = get_terms([ ‘taxonomy’ => $element->taxonomy, ‘parent’ => $element, ]); echo ‘<div style=”height: 200px; text-transform: uppercase; border:1px solid #666666; padding:10px; overflow-y: scroll;”> <div class=”breaker-small”>Refine Search</div>’; foreach ($terms as $term) { echo ‘<p class=”filters”><a href=”‘ . get_term_link($term) . ‘”>’ . $term->name . … Read more

How to make an If Else on Excerpt Filter

Here is the solution that seemed to work. Thanks Tom function new_excerpt_more($more) { global $post; $thePostID = $post->ID; if($thePostID == 1128) { return ‘…<a class=”readmore” href=”‘. get_permalink($post->ID) . ‘”>Watch Video &raquo;</a>’; } else { return ‘…<a class=”readmore” href=”‘. get_permalink($post->ID) . ‘”>Read more &raquo;</a>’; } } add_filter(‘excerpt_more’, ‘new_excerpt_more’);

Only Show One Category Name Per Post

You need to pass the category ID into get_category_link() <a href=”https://wordpress.stackexchange.com/questions/244678/<?php echo esc_url( get_category_link( $category[0]->term_id ) ); ?>”><?php echo $category[0]->cat_name; ?></a> Here’s the whole thing put together <?php $query = new WP_Query( array( ‘posts_per_page’ => 2, ‘categories_per_page’ => 1, ) ); while ( $query->have_posts() ) : $query->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/244678/<?php the_permalink(); ?>”><?php the_title(); ?></a></li> <?php … Read more

Slider Thumbnail Size Issue [closed]

You are on a good track. You first define your thumbnail sizes in your functions.php Make you upload big high-quality images but still good enough for the web You then need to regenerate your thumbnail, I recommend this plugin: https://wordpress.org/plugins/regenerate-thumbnails/ In you new code, you need to call your desired thumbnail based on the size … Read more

How to echo the translated custom field?

can you do this: get_post_meta(get_the_ID(), ”, true); print_r($meta); or get_post_meta(get_the_ID(), ‘my_custom_field’); print_r($meta); the first will pull all custom post type on the current post, and the second restricts to the field. You should get an array and then you’ll know which item in your array is the field title you’re looking to pull. then you … Read more