I have a plugin that I've created within my site, which just shows one page where I'm calling all users and then some specific information about those users.
Would it be possible to allow users to search for other existing users from the front end of the site?
This is the kind of thing I've got going on at the moment, I haven't been able to find any kind of search of this sort of thing, so if anyone could point me in the right direction it's be very much appreciated,
I haven't included any code as it's not that relevant really, but I can include it if needs be,
Thanks in advance!
http://focusedlearning.hcrlaw.com/courses-admin/
<?php $total_users = count_users();
$total_users = $total_users['total_users'];
$paged = get_query_var('paged');
$number = 20;?>
<?php
$args = array(
'order' => 'ASC',
'orderby' => 'display_name',
'count_total' => 'true',
'role' => 'subscriber',
'offset' => $paged ? ($paged) * $number : 0,
'number' => $number,
);?>
<?php
$blogusers = get_users($args);?>
<?php // Array of WP_User objects.
foreach ( $blogusers as $user ) {?>
<?php $userId = $user->ID;?>
<?php echo '<input type="text" value="' . esc_html( $user->display_name ) . '">';?>
<div id="content">
<h2>Completed Courses</h2>
<!-- COMPLIANCE-->
<?php
$post_args = array(
'post_type' => 'tribe_events',
'eventDisplay'=>'custom',
'start_date' => date( 'Y-m-d H:i:s', strtotime( '-365 days' ) ),
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'compliance',
),
),
'meta_query' => array(
array(
'key' => 'associated_people',
'value' => '"' . $userid . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
); ?>
<!-- MEMBERSHIP A -->
<?php if( rcp_is_active() && 2 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP A -->
<!-- MEMBERSHIP B -->
<?php if( rcp_is_active() && 3 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP B -->
<!-- MEMBERSHIP C -->
<?php if( rcp_is_active() && 4 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP C -->
<!-- MEMBERSHIP D -->
<?php if( rcp_is_active() && 5 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP D -->
<!-- MEMBERSHIP E -->
<?php if( rcp_is_active() && 6 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP E -->
<!-- END OF COMPLIANCE-->
Related
I am attempting to use a repeater with a post object inside as seen here:
Picture of ACF repeater with post object
It is only showing one out of two Reps:
Rep map
Here is the code I am using to attempt to accomplish this:
<?php
$args = array(
'post_type' => 'find-your-rep',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$loop = new WP_Query( $args );
$i = 0;
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); $i++ ?>
<span id="div<?php echo $i ?>" class="targetDiv">
<div class="repCard">
<?php if ( have_rows( 'reps' ) ) : ?>
<?php while ( have_rows( 'reps' ) ) : the_row(); ?>
<h3><?php the_sub_field( 'location' ); ?></h3>
<?php $rep = get_sub_field( 'rep' ); ?>
<?php if ( $rep ) : ?>
<?php $post = $rep; ?>
<?php setup_postdata( $post ); ?>
<div class="fullname"><?php the_title() ?></div>
<?php if ( get_field( 'company' ) ) : ?><div class="company">
<?php the_field( 'company' ); ?></div>
<?php endif; ?>
<?php if ( get_field( 'phone' ) ) : ?>
<div class="phone"><i class="phone icon"></i>
<a href="tel:<?php the_field( 'phone' ); ?>">
<?php the_field( 'phone' ); ?></a>.
</div>.
<?php endif; ?>
<?php if ( get_field( 'email' ) ) : ?>
<div class="email">
<i class="envelope icon"></i> <a href="mailto:<?php the_field( 'email' ); ?>">
<?php the_field( 'email' ); ?></a></div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
Sorry, there's no rep assigned to this location.
<?php endif; ?>
</div>
</span>
<?php endwhile; wp_reset_postdata(); ?>
I'd appreciate any help/direction to resolve this.
I have created this from advanced custom fields and would like to display a restaurant menu in rows and column. The first three columns are displaying as intended but for unknown reason the last column does not display within the table. As shown on the attached image, the last column is showing above the table header and I am not sure what's wrong with the code.
[
`
<table>
<thead>
<tr>
<td class="photo">Photo</td>
<td class="menu_name">Menu Item</td>
<td class="descriptions">Descriptions</td>
<td class="price">Price</td>
</tr>
</thead>
<?php while ( have_rows( 'restaurant_menu_items' ) ) : the_row(); ?>
<tr>
<td><?php $photo = get_sub_field( 'photo' ); ?>
<?php $size = 'thumbnail'; ?>
<?php if ( $photo ) : ?>
<?php echo wp_get_attachment_image( $photo, $size ); ?>
<?php endif; ?> </td>
<td> <?php the_sub_field( 'menu_name' ); ?></td>
<td><?php the_sub_field( 'descriptions' ); ?></td>
</td><?php the_sub_field( 'price' ); ?></td>
<?php endwhile; ?>
</tr>
</table>
<?php else : ?>
<?php // no rows found ?>
<?php endif; ?>`
you have typo error on the opening tag of the last td
**</td>**<?php the_sub_field( 'price' ); ?></td>
should be < td > without /
Hope it works! :)
Also, the tr tag is opening in while loop. So it should close in the while loop. Please check below code:
<?php while ( have_rows( 'restaurant_menu_items' ) ) : the_row(); ?>
<tr>
<td><?php $photo = get_sub_field( 'photo' ); ?>
<?php $size = 'thumbnail'; ?>
<?php if ( $photo ) : ?>
<?php echo wp_get_attachment_image( $photo, $size ); ?>
<?php endif; ?> </td>
<td> <?php the_sub_field( 'menu_name' ); ?></td>
<td><?php the_sub_field( 'descriptions' ); ?></td>
<td><?php the_sub_field( 'price' ); ?></td>
</tr>
<?php endwhile; ?>
This is my review-order.php table for woocommerce checkout
I cant seem to figure out why the last section with subtotal/shipping/total Displays Twice
I assume it must be something wrong with the code in second table?
Can i also add a column to first table to display product thumbnail? I have a snippet in my functions.php to add thumbnail here but i would prefer it was in a column of its own to the left of all the product info
<?php
defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
<tbody>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<br>
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</tbody>
</table>
<table>
<tfoot>
<tr class="cart-subtotal">
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<tr class="order-total">
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</tfoot>
</table>
Not sure if this is it but i noticed there are two table tags, one with tbody and the next with tfoot... wondering if upadting to a single table does anything:
<?php
defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
<tbody>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<br>
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</tbody>
<tfoot>
<tr class="cart-subtotal">
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<tr class="order-total">
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</tfoot>
</table>
My thought is there may be some js code somewhere adding the second one since there are two tables. Im still "debugging" to see if anything else jumps out at me.
Looking to display the individual number of each repeater row. So for example, the first row will display "1" and the second row will display "2".
I found this from Elliot,
<?php echo count( get_field('repeater_field') );?>
which counts how many rows there are in total. But I need the individual number next to each.
Thanks
I would suggest taking a look at Elliot's answer here:
http://support.advancedcustomfields.com/forums/topic/getting-instance-and-sort-of-id-of-repeater-field/
You would want to set up a counter variable ( $i ) and then add 1 to $i inside the loop.
<?php if( have_rows('repeater_field') ): $i = 0; ?>
<div class="repeater_loop">
<?php while( have_rows('repeater_field') ): the_row(); $i++; ?>
<p>This is row number <?php echo $i; ?>.</p>
<!-- call your sub_fields as needed -->
<?php endwhile; ?>
</div>
<?php endif; ?>
This would output a div with a paragraph tag that displays your row number.
<?php if( have_rows('tabel_produse_profit') ): $i = 0; ?>
<table width="100%" class="tab">
<tr>
<td>Nr.</td>
<td>Imagine</td>
<td>Nume</td>
<td>Evaluare</td>
<td>Verificati pretul</td>
</tr>
<?php while( have_rows('tabel_produse_profit') ): the_row(); $i++;
// vars
$image = get_sub_field('tabel_imagine_produs');
$link = get_sub_field('tabel_link_profit');
$titlu = get_sub_field('tabel_titlu_profit');
$evaluare = get_sub_field('tabel_evaluare');
$count = count(get_field('tabel_produse_profit'));
?>
<tr>
<td class="row1">
<?php echo $i; ?>
<?php if( $count ): ?>
<div class="rowc"> din <?php echo $count; ?></div>
<?php endif; ?>
</td>
<td class="row2">
<?php if( $image ): ?>
<img class="imag" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php endif; ?>
</td>
<td class="row3">
<?php if( $titlu ): ?>
<h2><?php echo $titlu; ?></h2>
<?php endif; ?>
</td>
<td class="row4">
<?php if( $evaluare ): ?>
<div class="eva"><?php echo $evaluare; ?></div>
<?php endif; ?>
</td>
<td class="row5">
<?php if( $link ): ?>
<a class="ver" href="<?php echo $link; ?>">VERIFICAȚI PREȚUL</a>
<div class="mag">pe emag.ro</div>
<?php endif; ?>
</td>
<?php echo $content; ?>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
There is get_row_index() already available to use.
I really can't figure this out. I'm trying to have posts all posts on a page from one category, but I still get all categories. This is the code I'm using now. I thought I could manage with WP_Query( array( 'posts_per_page' => -1, 'category_name' => 'resep' ) );, but it totally drives me nuts.
<?php /* Template Name: Blog */ ?>
<?php get_header(); ?>
<div id="content-wrap">
<div id="content">
<div class="post_content">
<h1 class="archive_title"><?php the_title(); ?></h1>
<?php
$query['post_type'] = 'post';
// WP 3.0 PAGED BUG FIX
if ( get_query_var('paged') )
$paged = get_query_var('paged');
elseif ( get_query_var('page') )
$paged = get_query_var('page');
else
$paged = 1;
//$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query['paged'] = $paged;
$recipe_posts = new WP_Query( array( 'posts_per_page' => -1, 'category_name' => 'resep' ) );
while ( $recipe_posts->have_posts() ) { $recipe_posts->the_post(); }
query_posts($query);
if (have_posts()) : ?>
<?php $more = 0; ?>
<div class="posts">
<?php while (have_posts()) : the_post();
$is_recipe = in_category('Resep'); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>>
<?php if (option::get('index_thumb') == 'on') {
get_the_image( array( 'size' => 'loop', 'width' => option::get('thumb_width'), 'height' => option::get('thumb_height'), 'before' => '<div class="post-thumb">', 'after' => '</div>' ) );
} ?>
<div class="details">
<h2 class="title"><?php the_title(); ?></h2>
<?php if ( option::get('display_meta') == 'on' ) { ?>
<div class="meta">
<?php
if ( $is_recipe ) {
$fields = get_fields();
if ( !empty( $fields ) ) echo $fields;
} else { ?>
<p><strong><img src="<?php echo get_template_directory_uri() . '/images/person.png'; ?>" /><?php _e('Author', 'wpzoom'); ?>:</strong><?php the_author_posts_link(); ?></p>
<p><strong><img src="<?php echo get_template_directory_uri() . '/images/clock.png'; ?>" />
<?php _e('Posted', 'wpzoom'); ?>
:</strong> <?php echo get_the_date(); ?></p>
<?php } ?>
</div>
<?php } ?>
<div class="entry">
<?php the_content('<span>'.__('Read More', 'wpzoom').' ›</span>'); ?>
</div>
<p>
<?php if ( option::get('display_readmore') == 'on' && (option::get('display_content') == 'Excerpt') ) { ?>
<a href="<?php the_permalink(); ?>" class=" clean more-link">
<?php _e( ( $is_recipe ? 'Lihat Resep' : 'Read More' ), 'wpzoom' ); ?>
</a>
<?php } ?>
<?php edit_post_link( __('Edit', 'wpzoom'), ' <small>', '</small>' ); ?>
</p>
</div>
<div class="cleaner"> </div>
</div>
<!-- /.post -->
<?php endwhile; ?>
</div>
<div class="cleaner"> </div>
<?php get_template_part( 'pagination' ); ?>
<?php wp_reset_query(); ?>
<div class="cleaner"> </div>
<?php endif; ?>
</div><!-- / .post_content -->
</div><!-- / #content -->
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
You're making it far too complex, just specificy the stuff you need inside the while loop:
$recipe_posts = new WP_Query( array( 'posts_per_page' => -1, 'category_name' => 'resep' ) );
while ( $recipe_posts->have_posts() ) {
$recipe_posts->the_post();
echo '<li>' . get_the_title() . '</li>';
}
wp_reset_query();
You have entered loop inside loop, try this following with cleaning your code:
$args = array('posts_per_page' => -1 , 'category_name' => 'resep');
$recipe_posts = new WP_Query($args);
if($recipe_posts->have_posts()) :
while($recipe_posts->have_posts()) :
$recipe_posts->the_post();
?>
<h1><?php the_title() ?></h1>
<div class='post-content'><?php the_content() ?></div>
<?php
endwhile;
else:
?>
Oops, there are no posts.
<?php
endif;
?>
I cleaned the whole template, but posts from other categories were still there. In the end I managed with these lines
global $wp_query;
$args = array_merge( $wp_query->query, array( 'category_name' => 'resep' ) );
query_posts( $args );
$recipe_posts = new WP_Query($args);
$more = 0;
if($recipe_posts->have_posts()) :
while ($recipe_posts->have_posts()) : $recipe_posts->the_post();?>