Single Loop With Dual Content Area

Lets first start with a bit of knowledge-base: the_content is this /** * Display the post content. * * @since 0.71 * * @param string $more_link_text Optional. Content for when there is more text. * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. */ function the_content( $more_link_text = null, … Read more

Eliminate duplicates in a foreach loop [closed]

Use array_unique() <?php foreach($users as $user) { $states[] = get_cimyFieldValue($user->ID, ‘STATE’); // Grabing their state from their profile page } $states = array_unique($states); ?> <div class=”state”> <input type=”hidden” name=”search_type” value=”members”> <select id=”stateDrop” name=”state”> <option value=”name”>State</option> <?php foreach($states as $state) { echo ‘<option value=”‘.$state.'”>’.$state.'</option>’; } ?> </select> </div>

How to defeat “Blog pages show at most __ posts” setting in the loop?

Instead of using the default loop, perhaps try building your own query. Basically, it’ll look something like this: $your_posts = get_posts(‘cat=123&posts_per_page=123’); foreach ($your_post as $post) { do_something-with($post); } You can display all posts by either use the param ‘posts_per_page’=>-1 or nopaging=true. (Not sure why someone voted this down? IMHO said person should comment on how … Read more

Show only posts from todays date [duplicate]

If you just want posts from today, it’s super easy and right in the WP codex: <?php $today = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $today[‘year’], ‘month’ => $today[‘mon’], ‘day’ => $today[‘mday’], ), ), ); $custom_query = new WP_Query( $args ); ?> <?php if ($custom_query->have_posts()) : while ($custom_query->have_posts()) : $custom_query->the_post(); ?> … Read more

How do I show the post title if an advanced custom field hasn’t been used?

If in doubt, check the documentation first: https://www.advancedcustomfields.com/resources/get_field/ Check if value exists This example shows how to check if a value exists for a field. $value = get_field( ‘text_field’ ); if ( $value ) { echo $value; } else { echo ’empty’; } So, in for your case you would need to use: <?php $short_testimonial … Read more

How wp maps urls into files

Go to “Pages” and find the page with the ID. Open it in editor. On the right hand side, look for “page attributes”. You can add php files here. All you have to do is, create a PHP page under your theme, and add this to your beginning of the file: <?php /* Template Name: … Read more

WooCommerce custom loop pagination on front page

Can you please try below code? $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $woo_home_query = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => $top_selling_products_nr, ‘meta_key’ => ‘total_sales’, ‘paged’ => $paged, ‘orderby’ => ‘meta_value_num’ ); <?php if ( $woo_home_query->have_posts() ) : ?> <div class=”products container grid-wrapper clear”> <div class=”row”> <?php while ( … Read more