How to query the content of a specific custom post type?

On your custom post type’s single page, you want to treat it similar to your standard post single template. For the most part, you should wrap everything in your single template in one loop like so: <? get_header(); ?> <? if(have_posts()): while(have_posts()): the_post(); ?> <!–Your content goes here–> <? endwhile; endif; ?> <? get_footer(); ?> … Read more

How to Order Posts by Custom Fields?

var_dump your $args arguments: array(4) { [“cat”]=> string(7) “2,39,30” [“orderby”]=> string(14) “meta_value_num” [“order”]=> string(4) “DESC” [“meta_key”]=> string(12) “album_rating” } The second time you use a key, you overwrite the first time. You cannot build the array like that. The orderby parameter will take a space separated string, so this is closer: $args = array( ‘cat’ … Read more

Time sort with meta_key using UNIX timestamp failing due to date differences

I will caveat this by saying that I am still not 100% sure I know what you are doing, but I believe the following will sort your results by time only assuming that your meta values are proper Unix timestamps. function orderby_time_only($orderby) { remove_action(‘posts_orderby’,’orderby_time_only’); return preg_replace(‘|(.*)\s(.*)|’,’DATE_FORMAT(FROM_UNIXTIME($1),”%k%i”) $2′,$orderby); } add_filter(‘posts_orderby’,’orderby_time_only’); $args = array( ‘post_type’ => ‘event’, … Read more

Can’t see custom field after the Loop [closed]

When you output your get_posts results and do this: setup_postdata($post); You overwrite the original value of $post which the_field uses to fetch the field data. It’s trying to get that field belonging to the last post in $products_mono_posts instead of the page that the field actually belongs to. After running custom queries where the value … Read more

Separate [Advanced Custom Field] values by commas

Try to grab the output and echo together. <?php $post_objects = get_field(‘field’); if($post_objects!=”) : $value = array(); ?> <?php foreach( $post_objects as $post): ?> <?php setup_postdata($post); ?> <?php $values[] = ‘<a href=”‘. get_permalink() .'”>’. the_title(”,”,false) .'</a>’; ?> <?php endforeach; ?> <?php endif; ?> <?php wp_reset_postdata(); ?> <?php echo join( ‘, ‘, $values); ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)