How to display a number of posts based on a Advanced Custom Field (ACF)

Found an answer to my question using the ACF plugin get_field function (http://www.advancedcustomfields.com/resources/functions/get_field/) to retrieve the value of the custom field, save it as a variable and then use it as part of the query_post parameters: <!– Modify query object –> <?php $num_news = get_field(“number_news”, 523); // number of news items to feature query_posts(‘showposts=”.$num_news.”&post_type=news’); ?> … Read more

Adding a custom field to do_shortcode [closed]

There’s a general convention in WordPress: functions prefixed with the_ will echo a value functions prefixed with get_ or get_the_ will return a value In your case you need to use get_sub_field() instead of the_sub_field() eg: echo do_shortcode( get_sub_field( ‘slideshare’ ) ); The documentation on the ACF site is very comprehensive: http://www.advancedcustomfields.com/resources/functions/get_sub_field/ NOTE: In your … Read more

Using WP meta query to show custom post types by a start and finish date

The query will by default GROUP BY the post ID, meaning that a post will only appear once in the list. You can remove that GROUP BY pretty easily with a filter: add_filter(‘posts_groupby’,’__return_empty_string’); $events = new WP_Query($args); remove_filter(‘posts_groupby’,’__return_empty_string’); That might get you what you want. It is a bit hard to tell. Without the GROUP … Read more

Remove Post if Advanced Custom Field is checked to fix paging

Use WP_Query instead, and you can use the meta_key / meta_value parameters: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘cat’ => 10, ‘paged’ => $paged, ‘posts_per_page’ => 12, ‘post_status’ => ‘any’, ‘order’ => ‘ASC’, ‘meta_key’ => ‘archived’, ‘meta_value’ => ‘true’ ); $posts = new WP_Query($args); ?> <?php while($posts->have_posts()): $posts->the_post(); ?> <?php … Read more

Get All In One SEO Pack to use custom field instead of Content

You can not specify which field, but you can use the filter *aioseop_description* to do whatever you want with the description before presenting. So technically, you can use your custom field as follows (untested) : add_filter(‘aioseop_description’,’my_custom_description’); global $post; function my_custom_description($text) { $mycustomseo = get_post_meta($post->ID, ‘my_custom_field’, true); return $mycustomseo; } Replace *my_custom_field* with your custom field. … Read more