Tag Info

New answers tagged

0

It is working with this, thanks @ialocin for your help : // show all active coupons for this store and setup pagination $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => APP_POST_TYPE, 'post_status' => 'publish', ...


0

Do NOT use query_posts() - it is bad, very bad to be exact. For more information read: When should you use WP_Query vs query_posts() vs get_posts()? When to use WP_query(), query_posts() and pre_get_posts Use WP_Query instead. Example with meta_key, meta_value and meta_compare parameters in use: $args = array( 'meta_key' => ...


1

it doesn't work (ie, the folder name will just be "User - " (with no ID Number) Did you check to see if and what bp_member_profile_data( 'field=ID Number' ); returns as a value? And that function will echo the value. To just return the value use bp_get_member_profile_data( 'field=ID Number' ); But... For God's sake... Why would you use a member loop ...


0

The problem was with exclude_from_search parameter when I registered the post type. exclude_from_search (boolean) (importance) Whether to exclude posts with this post type from front end search results. Default: value of the opposite of public argument 'true' - site/?s=search-term will not include posts of this post type. 'false' - ...


0

You should follow appropriate naming convention (aka Template Hierarchy) of your templates to make your job done. If I'm clear about your query here then I'd suggest you to name your custom taxonomy archive template(s) as "taxonomy-{your-taxonomy-name-here}.php" (i.e. taxonomy-vegetable.php, taxonomy-fruit.php and so on) There must not be any blank ...


0

You can try something like this $titels = ""; $content = ""; $html = ""; $counter = 1; while ( $custom_query->have_posts() ) : custom_query->the_post(); if ( counter % 5 = 0 ) : $html = "<div class='row'>" . $titels . $content . "</div>"; $titels = ""; $content = ""; endif; $titels .= "<div>". ...


0

Have you tried using rewind_posts()? It looks to me like what you'll have to do is either run the entire query only outputting titles then rewind and output content (however this would output all titles before the content, not in blocks of 5 as you have suggested) or wrap everything in a loop which runs the same query limited to 5 posts each time, then ...


1

As suggested, went to the function reference and from there to the Source File (located in wp_includes/link-template.php) in which there are four functions that each return similar results. <?php echo get_post_permalink() ?> http://newdep.localhost/instruments/jester/ <?php echo post_permalink() ?> ...


1

As Nilambar mentioned, the correct function is <?php the_permalink(); ?>. However, if you are using trial and error - try the WordPress Codex, particularly the_permalink for more info, examples and related functions.


0

You need to check against the value of layout: if ( get_theme_mod( 'layout' ) === 'stream' ) { // Stream } elseif ( get_theme_mod( 'layout' ) === 'grid' ) { // Grid } else { // Fallback }


0

You have a few issues here The use of 'no_found_rows' => true is incorrect. no_found_rows is meant for queries that will not be paginated. 'no_found_rows' => true is passed by get_posts to WP_Query to legally "break" pagination, that is why get_posts cannot be paginated as normal. What is really happening here is, by default is, when you query the ...


0

I think getting ALL the posts with the city = Melbourne and then checking ALL of them against ALL the posts that you are attempting to show on the page is the wrong way about it. Why not use the single loop that you should already have and put something like this to check if the city is Melbourne? <?php //check custom field 'city' $custom_field ...


3

Here is a concept that you can try out to exclude 5 posts per category each from category 3 and 5 where posts are excluded that belongs to category 9 and either of the before mentioned categories. Here is the function: (CAVEAT: Requires PHP 5.4+ as I used new short array syntax. Change as needed) /** * function get_sticky_category_posts() * * Get an ...


0

Please add ";" after $i = $i++ and see if that fixes your issue foreach ($socialIcons as $icon) { $i = $i++; $wp_customize->add_setting( 'pxk_href_' . $icon['name'], // use this in twig file call to theme_mod array( 'default' => '', 'transport' => 'postMessage', 'priority' => $i ) );


0

You are missing "foreach" loop. Try this way $latest_cpt = get_posts("post_type=event"); foreach ( $latest_cpt as $cpt_post ) { $theidone =$cpt_post->ID; $this_post_id = $theidone; //get_the_ID(); $key_2_value = get_post_meta( $this_post_id, 'custom_select', true ); if( ! empty( $key_2_value )) { $thisisworking = $key_2_value ...


2

This is an extention to your answer. Your pre_get_posts action has a few flaws function add_custom_types_to_tax( $query ) { if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { // Get all your post types $post_types = get_post_types(); $query->set( 'post_type', $post_types ); return $query; ...


0

Thanks to the comment by @Pieter Goosen advising it was probably something to do with pre_get_posts. I had a play around and certainlty it seems to have been the problem. This was my old code: Old Code function add_custom_types_to_tax( $query ) { if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { // Get ...


0

This is going to be a bit crappy to achieve without any potholes. The problems that you are going to face are If you are going to paginate one set of posts, the other two will also paginate regardless You are going to hit some kind of failure once you run out of posts on any of the three loops while paging through one of the other loops which have more ...


3

You might try this kind of pre_get_posts hook approach (untested): add_action( 'pre_get_posts', function( $q ) { $exclude_cats = [ 12, 34 ]; // <-- Edit these category ids! if( ! is_admin() && $q->is_main_query() && ! is_singular() && ! is_category( $exclude_cats ) ) { ...


0

Try this code: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC','cat' => '2', ); $loop = new WP_Query( $args ); ?> <?php if( $loop->have_posts() ): ?> ...


0

The fellow above was correct, however the string MUST be above: require_once(ABSPATH . 'wp-settings.php'); This is located within wp-config.php :)


0

You need to forward the http:// to https:// to avoid infinite loop. if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';


0

You can go with two queries, the first to get your taxonomies like this : $categories = get_categories(); More infos about the params here. And then browse your category collections and get the first n posts of it like this : foreach($categories as $cat) { //get the $n posts from this category $post_query = new WP_Query( array('post_type' ...


2

Try using the count variable to increment the loop. <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <?php if(get_field('faq_general_ht')): ?> <?php $count=0; ?> <?php while(has_sub_field('faq_general_ht')): ?> <div class="panel panel-default"> ...


1

UPDATE: Ok this should work, according to ACF's documentation: $args = array( 'posts_per_page' => -1, 'post_type' => 'page', 'meta_query' => array( array( 'key' => 'feature_on_front_page', 'value' => 'featured', 'compare' => 'LIKE' ), ) ); Your ...


-1

Try "posts_per_page" in place of "numberposts". numberposts is not a valid parameter of WP_Query. if you are using "ACF", then I think this will not work with WP_Query. This is not logical but I had same kind of bad experience. Try once


0

This filter has to be set in functions.php. Your filter won't work as expected because your condition is wrong. The condition here imply that you try to order pages (hierarchical post) instead of regular posts-like entries. You have to be careful using this filter as it has effect on your whole website. function my_custom_archive_order( $vars ) { if ( ...



Top 50 recent answers are included