PHP Conditional Issue - php

I have a small problem. And I am not sure why am I getting this problem. See what I did was I limited a page to "Public Member" and I want this page to be access Library members too because library members would have access to all pages. So what I did was I added a simple condition like this:
if ( $user_role == "library-Member" && $pageLevel == "public-member" ) {
$displayPost = "true";
}
And in my post I added this condition
if ( $displayPost == "true" ) {
.. execute html stuff ..
}
else {
wp_redirect( 'http://sample.org/restricted-area' );
exit;
}
But somehow the condition is not working. I have also checking var_dump($displayPost) the output is true
Can someone help me please? Thanks.
EDIT
Image Samples:
1. Sample 1
2. Sample 2
CODE:
<?php
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
if ( !is_user_logged_in() ) { $user_role = array( 'public-member' ); }
$pageLevel = get_post_meta( $post->ID, 'user_type', true );
if ( $user_role == "library-Member" && $pageLevel == "public-member" ) {
$displayPost = "true";
}
if ( $displayPost == "true" ) {
?>
<div class="main wrap cf">
<div class="row">
<div class="col-8 main-content">
<?php if (have_posts()): the_post(); endif; // load the page ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('page-content'); ?>>
<?php if (Bunyad::posts()->meta('page_title') != 'no'): ?>
<header class="post-header">
<?php if (has_post_thumbnail()): ?>
<div class="featured">
<a href="<?php $url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); echo $url[0]; ?>" title="<?php the_title_attribute(); ?>">
<?php if ((!in_the_loop() && Bunyad::posts()->meta('layout_style') == 'full') OR Bunyad::core()->get_sidebar() == 'none'): // largest images - no sidebar? ?>
<?php the_post_thumbnail('main-full', array('title' => strip_tags(get_the_title()))); ?>
<?php else: ?>
<?php the_post_thumbnail('main-slider', array('title' => strip_tags(get_the_title()))); ?>
<?php endif; ?>
</a>
</div>
<?php endif; ?>
<h1 class="main-heading">
<?php the_title(); ?>
</h1>
</header><!-- .post-header -->
<?php endif; ?>
<?php Bunyad::posts()->the_content(); ?>
</div>
</div>
<?php Bunyad::core()->theme_sidebar(); ?>
</div> <!-- .row -->
</div> <!-- .main -->
<?php
} else {
wp_redirect( 'http://sample.org/restricted-area' );
exit;
}
?>

Related

woocommerce function to get svg code product icon

I have add a new field via admin panel in products product_icon
where I put an SVG icon code. I need to use this SVG plugin. I have put into woocommerce/includes/abstracts/abstract-wc-product.php new function.
public function get_icon( $context = 'view' ) {
return $this->get_prop( 'icon', $context );
}
when I put it into a while loop where I have list products name, prices, etc new function get_icon() I have null. In SQL post meta meta key is ok "product_icon" for a correct product with the correct content (SVG code)
My listing Code:
<?php
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$product = wc_get_product( get_the_ID() );
?>
<div class="eb-woo-products-col">
<?php if ( 'grid' === $layout && 'grid-preset-3' === $gridPreset ) { ?>
<div class="producttabwhite eb-woo-product">
<?php } else { ?>
<div class="producttabblue eb-woo-product">
<?php } ?>
<div id="mydiv" class="eb-woo-product-image-wrapper" style="margin-top:2.5rem;margin-right:1.25rem;">
<?php echo wp_kses_post( $product->get_image( 'woocommerce_thumbnail' ) ); ?>
<?php if ( 'grid' === $layout ) { ?>
<div class="eb-woo-product-overlay">
<div class="eb-woo-product-button-list">
<?php // woocommerce_template_loop_add_to_cart(); ?>
</div>
</div>
<?php } ?>
</div>
<div class="eb-woo-product-content-wrapper1">
<div class="ml40px mt33px col-sm-8">
<?php if ( 'grid' === $layout && 'grid-preset-3' === $gridPreset ) { ?>
<p class="producttitle">
<a class="producttitle" href="<?php echo esc_url( get_permalink() ); ?>"><?php echo get_the_title(); ?></a>
</p>
<?php } else { ?>
<p class="producttitlewhite">
<a class="producttitlewhite" href="<?php echo esc_url( get_permalink() ); ?>"><?php echo get_the_title(); ?></a>
</p>
<?php } ?>
<?php if ( 'grid' === $layout && 'grid-preset-3' === $gridPreset ) { ?>
<p class="productprice">
<?php if ( $showPrice ) { ?>
<p><?php echo $product->get_price_html(); ?></p>
<p>Icon code<?php echo $product->get_icon(); ?></p>
<div style="display:block" class="mt-4 eb-woo-product-button-list"><?php woocommerce_template_loop_add_to_cart(); ?></div>
<?php } ?>
</p>
<?php } else { ?>
<p class="productpricewhite">
<?php if ( $showPrice ) { ?>
<p><?php echo $product->get_price_html(); ?></p>
<div style="display:block" class="mt-4 eb-woo-product-button-list"><?php woocommerce_template_loop_add_to_cart(); ?></div>
<?php } ?>
</p>
<?php } ?>
</div>
</div>
</div>
</div>
<?php
}
wp_reset_postdata();
} else {
?>
<p><?php _e( 'No product found', 'essential-blocks' ); ?></p>
<?php
}
?>
Well, you don't have to edit woocommerce/includes/abstracts/abstract-wc-product.php file to fetch the meta key and the get_prop function doesn't work that way that you're assuming.
You can simply use get_post_meta function to fetch your meta key value for the product.
so you just need to replace <p><?php echo $product->get_icon(); ?></p>
with the below code:
<p><?php echo get_post_meta( $product->get_id(), 'product_icon', true ); ?></p>

only displays certain category

I'm building my own website just for fun and for learning.
I want to display only the post with a certain category # my homepage.
I've tried a number of things but they don't seem to work
at my home.php
this is what te code looks like.
get_header(); ?>
<?php $blog_layout = get_theme_mod('blog_layout', 'small-images'); ?>
<?php if ( ($blog_layout == 'masonry') || ($blog_layout == 'fullwidth') ) {
$layout = 'fullwidth';
} else {
$layout = '';
} ?>
<?php if ( $blog_layout == 'masonry' ) {
$masonry = 'home-masonry';
} else {
$masonry = '';
} ?>
<div id="primary" class="content-area <?php echo $layout; ?>">
<main id="main" class="site-main" role="main">
<span class="diensten">ONZE DIENSTEN..</span>
<div class="diensten-content">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<div class="home-wrapper <?php echo $masonry; ?>">
<?php while ( have_posts() ) : the_post(); ?>
<?php
if ( $blog_layout == 'large-images' || $blog_layout == 'masonry' ) {
get_template_part( 'content', 'large' );
} else {
get_template_part( 'content', get_post_format() );
}
?>
<?php endwhile; ?>
</div>
<?php moesia_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div><!--diensten-content-->
<
</main><!-- #main -->
</div><!-- #primary -->
And at content.php
<article id="post-<?php the_ID(); ?>" <?php post_class(''); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb">
<a href="<?php the_permalink(); ?>" class="H1-posts" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('moesia-thumb'); ?>
</a>
</div>
<?php endif; ?>
<?php if (has_post_thumbnail()) : ?>
<?php $has_thumb = ""; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="post-content <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
<?php if ( 'post' == get_post_type() ) : ?>
<?php endif; ?>
</header><!-- .entry-header -->
<div class="entry-summary">
<?php if ( (get_theme_mod('full_content') == 1) && is_home() ) : ?>
<?php the_content(); ?>
<?php else : ?>
<?php the_excerpt(); ?>
<?php endif; ?>
</div><!-- .entry-content -->
I've tried this..`
<?php
//refine your query to the category you desire either a slug(example below) or category id
$args = array(
'category_name' => 'my_category_slug',
);
//create the query using the arguments
$query = new WP_Query($args);
?>
//create the loop to show the posts
<?php if($query->have_posts()): ?>
<?php while($query->have_posts()): $query->the_post(); ?>
<h1><?php the_title(); ?></h1>
<div><?php the_content(); ?></div>
<?php endwhile; ?>
<?php endif; ?>
did not work. How do I fix this?`If It displays only the posts with a certain class if also good.
Thanks..

Remove excerpts from homepage

My page is http://prowrestlingnews.co. I am looking to remove the excerpts from the homepage, as this is a news headline website. I prefer for the main content (middle section) to display headlines like it does on the right sidebar with the "Latest Wrestling News" widget.
I have been playing around with the index and functions file, but can't seem to remove the excerpts. Any help would be greatly appreciated!
Here's the index.php file:
<?php
/**
* The main template file.
*
* Used to display the homepage when home.php doesn't exist.
*/
?>
<?php $mts_options = get_option(MTS_THEME_NAME); ?>
<?php get_header(); ?>
<div id="page">
<div class="article">
<div id="content_box">
<?php if ( !is_paged() ) { ?>
<?php if ( is_home() && $mts_options['mts_featured_slider'] == '1' ) { ?>
<div class="primary-slider-container clearfix loading">
<div id="slider" class="primary-slider">
<?php if ( empty( $mts_options['mts_custom_slider'] ) ) { ?>
<?php
// prevent implode error
if ( empty( $mts_options['mts_featured_slider_cat'] ) || !is_array( $mts_options['mts_featured_slider_cat'] ) ) {
$mts_options['mts_featured_slider_cat'] = array('0');
}
$slider_cat = implode( ",", $mts_options['mts_featured_slider_cat'] );
$slider_query = new WP_Query('cat='.$slider_cat.'&posts_per_page='.$mts_options['mts_featured_slider_num']);
while ( $slider_query->have_posts() ) : $slider_query->the_post();
?>
<div>
<a href="<?php echo esc_url( get_the_permalink() ); ?>">
<?php the_post_thumbnail('schema-slider',array('title' => '')); ?>
<div class="slide-caption">
<h2 class="slide-title"><?php the_title(); ?></h2>
</div>
</a>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<?php } else { ?>
<?php foreach( $mts_options['mts_custom_slider'] as $slide ) : ?>
<div>
<a href="<?php echo esc_url( $slide['mts_custom_slider_link'] ); ?>">
<?php echo wp_get_attachment_image( $slide['mts_custom_slider_image'], 'schema-slider', false, array('title' => '') ); ?>
<div class="slide-caption">
<h2 class="slide-title"><?php echo esc_html( $slide['mts_custom_slider_title'] ); ?></h2>
</div>
</a>
</div>
<?php endforeach; ?>
<?php } ?>
</div><!-- .primary-slider -->
</div><!-- .primary-slider-container -->
<?php } ?>
<?php
$featured_categories = array();
if ( !empty( $mts_options['mts_featured_categories'] ) ) {
foreach ( $mts_options['mts_featured_categories'] as $section ) {
$category_id = $section['mts_featured_category'];
$featured_categories[] = $category_id;
$posts_num = $section['mts_featured_category_postsnum'];
if ( 'latest' == $category_id ) { ?>
<?php $j = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article>
<?php endwhile; endif; ?>
<?php if ( $j !== 0 ) { // No pagination if there is no posts ?>
<?php mts_pagination(); ?>
<?php } ?>
<?php } else { // if $category_id != 'latest': ?>
<h3 class="featured-category-title"><?php echo esc_html( get_cat_name( $category_id ) ); ?></h3>
<?php
$j = 0;
$cat_query = new WP_Query('cat='.$category_id.'&posts_per_page='.$posts_num);
if ( $cat_query->have_posts() ) : while ( $cat_query->have_posts() ) : $cat_query->the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article>
<?php
endwhile; endif; wp_reset_postdata();
}
}
}
?>
<?php } else { //Paged ?>
<?php $j = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article>
<?php endwhile; endif; ?>
<?php if ( $j !== 0 ) { // No pagination if there is no posts ?>
<?php mts_pagination(); ?>
<?php } ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Functions.php file viewed at https://gist.github.com/pwz2k/16a8aa858ee3d739276c67d56fbccca9

add badge to thumbnail image

What I want to do on the front page where I have recent posts, is to add a small upper corner badge or ribbon that says "NEW" to the thumbnails of posts that were published on today's date. Below is my index.php which controls the front page layout:
<?php
/**
* The main template file.
*
* Used to display the homepage when home.php doesn't exist.
*/
?>
<?php
// Get options
$mts_options = get_option(MTS_THEME_NAME);
// Featured Section 1 settings ( slider is here) --------------------------------
$slider_enabled = ( $mts_options['mts_featured_slider'] === '1' ) ? true : false;
if ( empty($mts_options['mts_featured_slider_cat']) || !is_array($mts_options['mts_featured_slider_cat']) ) {
$mts_options['mts_featured_slider_cat'] = array('0');
}
$slider_cat = implode(",", $mts_options['mts_featured_slider_cat']);
// Featured Section settings --------------------------------------------------
$f2_title = $mts_options['mts_featured_section_2_title'];
if ( empty($mts_options['mts_featured_section_2_cat']) || !is_array($mts_options['mts_featured_section_2_cat']) ) {
$mts_options['mts_featured_section_2_cat'] = array('0');
}
$f2_cat= implode(",", $mts_options['mts_featured_section_2_cat']);
// Featured Section 3 settings --------------------------------------------------
get_header(); ?>
<div id="page">
<div class="article">
<?php if ( $slider_enabled && is_home() && !is_paged() ) { ?>
<section id="featured-section-1" class="featured-section featured-section-1-1 clearfix">
<div class="slider-container">
<div class="primary-slider-container clearfix loading">
<div id="slider" class="primary-slider">
<?php
$slider_full = 'best-featuredfull';
if ( empty( $mts_options['mts_custom_slider'] ) ) {
$my_query = new WP_Query('cat='.$slider_cat.'&posts_per_page='.$mts_options['mts_featured_slider_num']);
while ( $my_query->have_posts() ) : $my_query->the_post();
?>
<div>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail($slider_full,array('title' => '')); ?>
<div class="slider-caption">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']) && $mts_options['mts_home_headline_meta_info']['enabled']){ ?>
<div class="sliderdate">
<?php if(isset($mts_options['mts_home_headline_meta_info']['enabled']['date']) == '1') { ?>
<span class="thetime updated"><?php the_time( get_option( 'date_format' ) ); ?></span>
<?php } ?>
</div>
<?php } ?>
<h2 class="slide-title"><?php the_title(); ?></h2>
</div>
<div class="post-day"><?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'review-total-only'); ?></div>
</a>
</div>
<?php endwhile; wp_reset_postdata();
} else { ?>
<?php foreach( $mts_options['mts_custom_slider'] as $slide ) : ?>
<div>
<a href="<?php echo esc_url( $slide['mts_custom_slider_link'] ); ?>">
<?php echo wp_get_attachment_image( $slide['mts_custom_slider_image'], $slider_full, false, array('title' => '') ); ?>
<div class="slider-caption">
<div class="sliderdate"><?php echo esc_html( $slide['mts_custom_slider_title'] ); ?></div>
<h2 class="slide-title"><?php echo esc_html( $slide['mts_custom_slider_text'] ); ?></h2>
</div>
</a>
</div>
<?php endforeach; ?>
<?php } ?>
</div>
</div>
</div><!-- slider-container -->
</section>
<?php } ?>
<?php if( $mts_options['mts_featured_section_2'] === '1' && is_home() && !is_paged() ) {// featured section 2 ?>
<section id="featured-section-3" class="featured-section clearfix">
<?php if (!empty($f2_title)) { ?><h4 class="featured-section-title"><?php echo $f2_title;?></h4><?php } ?>
<?php
$f2_query = new WP_Query('cat='.$f2_cat.'&posts_per_page=4');
$f2_count = 1; if ($f2_query->have_posts()) : while ($f2_query->have_posts()) : $f2_query->the_post();
$f2_loop_params = best_mixed_layout_params( 1, 2, $f2_count );// see functions.php
$f2_clear_class = $f2_loop_params['clear_class'];
$f2_type_class = $f2_loop_params['box_class'];
$f2_loop_thumb = $f2_loop_params['thumb'];
$f2_show_excerpt = $f2_loop_params['show_excerpt'];
$f2_show_author = $f2_loop_params['show_author'];
$begin_f2_extra_wrappers = $f2_loop_params['open_wrappers'];
$end_f2_extra_wrappers = $f2_loop_params['close_wrappers'];
?>
<article class="post-box latestPost mixed <?php echo $f2_type_class;?> <?php echo $f2_clear_class;?>">
<?php echo $begin_f2_extra_wrappers; ?>
<div class="post-img">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="nofollow">
<?php the_post_thumbnail($f2_loop_thumb,array('title' => '')); ?>
</a>
</div>
<div class="post-data">
<div class="post-data-container">
<header>
<h2 class="title post-title"><?php the_title(); ?></h2>
<?php mts_the_postinfo(); ?>
</header>
<?php if ($f2_show_excerpt) : ?>
<div class="post-excerpt">
<?php echo mts_excerpt(40); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php echo $end_f2_extra_wrappers; ?>
</article><!--.post-box-->
<?php $f2_count++; endwhile;
endif; wp_reset_postdata();
?>
</section><!--#featured-section-3-->
<?php } ?>
<div id="content_box">
<?php $latest_posts_used = false;
if ( !empty( $mts_options['mts_featured_categories'] ) ) {
foreach ( $mts_options['mts_featured_categories'] as $section ) {
$category_id = $section['mts_featured_category'];
$featured_category_layout = $section['mts_featured_category_layout'];
$posts_num = $section['mts_featured_category_postsnum'];
if ( $category_id === 'latest' && ! $latest_posts_used ) {
$latest_posts_used = true;
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section id="latest-posts" class="clearfix<?php echo $fc_section_class ?><?php //echo $fc_section_no_gap ?>">
<h4 class="featured-section-title"><?php _e( "Latest", "best" ); ?></h4>
<?php $j = 1; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j, true );?>
<?php $j++; endwhile; endif; ?>
<!--Start Pagination-->
<?php if (isset($mts_options['mts_pagenavigation_type']) && $mts_options['mts_pagenavigation_type'] == '1' ) { ?>
<?php $additional_loop = 0; mts_pagination($additional_loop['max_num_pages']); ?>
<?php } else { ?>
<div class="pagination pagination-previous-next">
<ul>
<li class="nav-previous"><?php next_posts_link( '<i class="fa fa-chevron-left"></i> '. __( 'Previous', 'best' ) ); ?></li>
<li class="nav-next"><?php previous_posts_link( __( 'Next', 'best' ).' <i class="fa fa-chevron-right"></i>' ); ?></li>
</ul>
</div>
<?php } ?>
<!--End Pagination-->
</section><!--#latest-posts-->
<?php } elseif ( $category_id !== 'latest' && !is_paged() ) {
$fc_section_class = ( in_array( $featured_category_layout, array( 'vertical', 'mixed' ) ) ) ? '' : ' '.$featured_category_layout;
?>
<section class="featured-section clearfix<?php echo $fc_section_class ?>">
<h4 class="featured-section-title"><?php echo get_cat_name($category_id); ?></h4>
<?php $cat_query = new WP_Query('cat='.$category_id.'&posts_per_page='.$posts_num); ?>
<?php $j = 1; if ($cat_query->have_posts()) : while ($cat_query->have_posts()) : $cat_query->the_post(); ?>
<?php best_the_homepage_article( $featured_category_layout, $j );?>
<?php $j++; endwhile; endif; wp_reset_postdata();?>
</section>
<?php } ?>
<?php } ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
What I have is this: to check the date and display the badge (not including css) but not sure where to input it exactly:
<?php
$days_old = (current_time(timestamp) - get_the_time('U') - (get_settings('gmt_offset') *3600 ) ) / (60*60*24);
if ($days_old <=1) {
echo <div class="post-badge">NEW</div>;
}
?>
I want to insert it into The Latest Post Section. Any help would be greatly appreciated:)

Change the order of returned posts

I have written a neat responsive slider for my Wordpress featured articles (feel free to use it):
<?php
$responsive = 'on' != get_option('henrik_responsive_layout') ? false : true;
$featured_auto_class = '';
if ( 'on' == get_option('henrik_slider_auto') ) $featured_auto_class .= ' et_slider_auto et_slider_speed_' . get_option('henrik_slider_autospeed');
?>
<div id="featured" class="<?php if ( $responsive ) echo 'flexslider' . $featured_auto_class; else echo 'et_cycle'; ?>">
<a id="left-arrow" href="#"><?php esc_html_e('Previous','henrik'); ?></a>
<a id="right-arrow" href="#"><?php esc_html_e('Next','henrik'); ?></a>
<?php if ( $responsive ) { ?>
<ul class="slides">
<?php } else { ?>
<div id="slides">
<?php } ?>
<?php global $ids;
$ids = array();
$arr = array();
$i=0;
$featured_cat = get_option('henrik_feat_cat');
$featured_num = (int) get_option('henrik_featured_num');
if (get_option('henrik_use_pages') == 'false') query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat));
else {
global $pages_number;
if (get_option('henrik_feat_pages') <> '') $featured_num = count(get_option('henrik_feat_pages'));
else $featured_num = $pages_number;
query_posts(array
('post_type' => 'page',
'orderby' => 'menu_order',
'order' => 'ASC',
'post__in' => (array) get_option('henrik_feat_pages'),
'showposts' => (int) $featured_num
));
} ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
global $post; ?>
<?php if ( $responsive ) { ?>
<li class="slide">
<?php } else { ?>
<div class="slide">
<?php } ?>
<?php
$width = $responsive ? 960 : 958;
$height = 340;
$small_width = 95;
$small_height = 54;
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,'',$titletext,$titletext,false,'Featured');
$arr[$i]['thumbnail'] = get_thumbnail($small_width,$small_height,'',$titletext,$titletext,false,'Small');
$arr[$i]['titletext'] = $titletext;
$thumb = $thumbnail["thumb"];
print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, ''); ?>
<div class="featured-top-shadow"></div>
<div class="featured-bottom-shadow"></div>
<div class="featured-description">
<div class="feat_desc">
<p class="meta-info"><?php esc_html_e('Posted','henrik'); ?> <?php esc_html_e('by','henrik'); ?> <?php the_author_posts_link(); ?> <?php esc_html_e('on','henrik'); ?> <?php the_time(esc_attr(get_option('henrik_date_format'))) ?></p>
<h2 class="featured-title"><?php the_title(); ?></h2>
<p><?php truncate_post(410); ?></p>
</div>
<?php esc_html_e('Read More', 'henrik'); ?>
</div> <!-- end .description -->
<?php if ( $responsive ) { ?>
</li> <!-- end .slide -->
<?php } else { ?>
</div> <!-- end .slide -->
<?php } ?>
<?php $ids[] = $post->ID; $i++; endwhile; endif; wp_reset_query(); ?>
<?php if ( $responsive ) { ?>
</ul> <!-- end .slides -->
<?php } else { ?>
</div> <!-- end #slides -->
<?php } ?>
</div> <!-- end #featured -->
<div id="controllers" class="clearfix">
<ul>
<?php for ($i = 0; $i < $featured_num; $i++) { ?>
<li>
<div class="controller">
<a href="#"<?php if ( $i == 0 ) echo ' class="active"'; ?>>
<?php print_thumbnail( $arr[$i]['thumbnail']['thumb'], $arr[$i]['thumbnail']["use_timthumb"], $arr[$i]['titletext'], $small_width, $small_height ); ?>
<span class="overlay"></span>
</a>
</div>
</li>
<?php } ?>
</ul>
<div id="active_item"></div>
</div> <!-- end #controllers -->
It selects a custom category and returns a custom amount of posts. The problem is that it will display the posts in the order of which they were created. I want to choose my own order, so that I can select which posts displays first and so on.
So, is it possible to select which order the returned posts are displayed? Maybe by targeting specific IDs?
It looks like you're already doing this by using 'orderby' => 'menu_order'. All you need to do now is set the menu order in the WordPress interface -- all new posts default to 0. Or you change the orderby argument to something else.

Categories