Tag Info

New answers tagged

0

You should clean it up some more but this will fix your code: <?php get_header(); ?> <div class="posts"><!-- BLOG --> <!-- Shapes on sides --> <div class="shapes_left"> </div> <div class="shapes_right"> </div> <?php if (is_tag()) { ?> <div id="archive_title"> ...


0

The correct iteration of the loop is: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> and ends here: <?php endwhile; else : ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?> For more details on the loop see https://codex.wordpress.org/The_Loop Also I am not ...


0

This is the source of all your problems: <?php if(is_home() && !is_paged()) { ?> <?php query_posts(array('post__in'=>get_option('sticky_posts'))); ?> This takes the current query, and puts it to one side, and places a new query in its place. Here you're saying that you want to show the first page of sticky posts. You ...


0

You can get & list all categories, with sub-categories, like a "tree"! see solution: How to sort list of custom posts to get view like a tree of posts under categories and their children's categories?


1

Is there a reason to execute the query in each individual div instead of looping the div within the query? <?php $my_query = new WP_Query( 'post_type=portfolio&showposts=13' ); while ( $my_query->have_posts() ) : $my_query->the_post(); ?> <div class="port1"> <?php the_title(); ?> </div> <?php endwhile; ?> ...


1

You could use in_array() with get_queried_object_id(): if( is_category() && in_array( get_queried_object_id(), $archive_categories ) ){ echo 'stuff'; } else { theme_loop(); }


2

I made a few adjustments. Once I created my two arrays, I combined them this way $merged_queries->posts = array_merge( $women->posts, $men->posts ); shuffle($merged_queries->posts); $merged_queries->post_count = $women->post_count + $men->post_count; while ( $merged_queries->have_posts() ) { $merged_queries->the_post(); // do ...


2

I think the best way here would be to run three separate loops here (you can also do two loops, but then you need to get full posts in the men and women queries, combine them and shuffle them), the first two will be used to get 5 men and the second loop will get 2 women. You can adjust this as necessary. The third loop will use the info from the first two ...


0

This code here is the problem- $('.slider-menu li').on('click', function(e) { e.preventDefault(); var slide_index = $('a', this).attr('href').substr(6) - 1; $homeSlider.flexslider(slide_index); return false; // IE9 hack }); In your html, you're setting your IDs to slide plus the attachment ID, then telling flexslider to animate to that ...


0

You can run the same loop multiple times by using rewind_posts() to output each type separately. if( have_posts() ){ $types = array('post', 'lesson', 'series'); foreach( $types as $type ){ echo 'your container opens here for ' . $type; while( have_posts() ){ the_post(); if( $type == get_post_type() ){ ...


0

So, if you want to display only posts on your homepage, which interests the logged in user, you can use the pre_get_posts-Action: add_action( 'pre_get_posts', 'wp123234_user_specific_loop' ); function wp123234_user_specific_loop( $query ){ if( ! is_user_logged_in() ) //Just return, if the user is not logged in. return; if( ! ...


0

.active class of flexslider is not specific to WordPress, so off-topic here. BTW, a simple WP_Query(), get_posts(), get_children() etc. never affects the flexslider performance. What you have to follow is the syntax provided by the flexslider. Please note: <div class="flexslider"> <ul class="slides"> //loop starts <li> ...


0

Try to replace the following: <?php $sectyp = array( 'meta_query' => array( array( 'key' => 'section_type', // selecting the section type "Normal" or "Parallax" 'value' => 'Parallax' ), ), ); ?> with <?php $sectyp = ...


1

Primary issue with your function is "get_template_part" internally use global $post variable to display the post fields. However, your $post variable is filled for this function only. I would suggest to read this handy article Displaying Posts Using a Custom Select Query Now, specifically in your case function lugaresincreibles_most_commented() { ...


1

Don't create a new query and loop just to alter posts per page. Add a function hooked to pre_get_posts and alter whatever parameters you want in there before the query is run. This would go in your theme's functions.php file, or a plugin. function wpd_testimonials_query( $query ){ if( ! is_admin() && $query->is_post_type_archive( ...


0

first, read this about query_posts. to answer your question- has_post_thumbnail() returns true or false, iterating over that in a foreach loop isn't possible. I'll guess that the reason why the same modal appears to be repeated is that you're giving them all the same id, so the first one is always opened. Use the post's ID to make those unique to each ...


2

I think the general suggestion is to use WP_Query instead of query_posts partly because query_posts used WP_query in a simplified way and can cause problems down the road. So for sure check out the WP_Query page, specifically the Multiple Loops example: http://codex.wordpress.org/Class_Reference/WP_Query#Multiple_Loops So the code using WP_Query would look ...


0

Your categories are, shopping , concerts and sports. So in order to create a category archive, you should follow category-{category-slug}.php Hence your file name should be : category-shopping.php category-sports.php category-concerts.php. And after this try with /event/category/concerts/ - this will solve your problem.


0

Two issues here The default page post type is page, not pages Your meta_query is wrong, it should be an array of an array, not just an array Your arguments should be $args = array( 'post_type' => 'page', 'order' => 'ASC', 'posts_per_page' => 50, 'meta_query' => array( array( 'key' ...


2

Change if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); to if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); Why? When you call $the_query = new WP_Query($query); you're storing the loop in a variable called $the_query. $query is an array of arguments that ...


0

Ok mate - i got you... you should really break into 2 shortcodes. One as a wrapper (which is really short) and the other for the content... Example: add_shortcode('servicewrap', 'service_wrapsc'); function service_wrapsc($atts, $content = null) { return '<div class="service"><div class="container"><div ...


0

If you take a look at the WordPress Codex 'post_excerpt' is not a valid parameter for the 'orderby' parameter For this reason it cannot be done through WP_Query(). If you don't mind, why are you trying to sort by post_excerpt in the first place?


0

I solved this in a very easy way, using an array for the ordering, as below: $posts = get_posts(array( 'orderby' => array( 'meta_key' => 'meta_key', /* your meta key here */ 'meta_value' => 'meta_value_num', 'order' => 'DESC', ) ...


0

Hi this may be a solution to your problem. Instead of putting: <?php echo $embedUrl; ?> Put it like this: <?php echo substr($embedUrl, 0, 11); ?> it will echo only the 11 character code after the v= of the extracted Youtube link on the video post content. I have tested it myself and came with this solution. Hope this helps!


2

You need to call global $post before using $post->ID, or better, use get_the_ID() instead.


0

You are most probably not doing this on a static front page, so your paged parameter is using wrong values. Static front pages uses get_query_var( 'page' ) to calculate pagination, all other pages uses get_query_var( 'paged' ) You need to also set the $max_pages parameter in next_posts_link. Without that, your links won`t display <p ...


0

Just make sure that the code you have write in archive-{post_type}.php file or you can use ajax pagination if you need to use page template: Add this 'has_archive' => 'page template' when you register the custom post type


2

You need to specify the post type to be a post - try this for your $args instead: $args = array( 'post_type' => 'post', // Specifying you want posts only 'posts_per_page' => 1, 'orderby' => 'rand', 'post_status' => 'publish', ); And most importantly, you need to apply the $args to your query, so do this ...


1

If you're altering the main query, always use pre_get_posts to alter query parameters before the query is run and before the template is loaded. This will be the most efficient and will not break pagination. As of v4, orderby accepts an array of arguments, which gives you the ability to have different order for each if necessary: function my_get_posts( ...


0

There is ability to sort by more than one column. See here. $args = array( 'posts_per_page' => 99, 'orderby' => 'menu_order title', 'order' => 'ASC', ); $query = new WP_Query( $args ); // do your stuff here... wp_reset_postdata(); Check out standard loop and why you should use wp_reset_postdata.


1

You cannot mix array syntax and string syntax in the same argument. If you start with array syntax, you should stick with that, the same applies if you start with string syntax, then you should stick with string syntax. Because you are using post__not_in which is an array, you should stick with array syntax <?php $query = new WP_Query( array( ...


0

Please Try This To Get Post in DESC order $args = array( 'orderby' => 'title', 'order' => 'DESC', 'author' =>'authorName', ); $query = new WP_Query( $args ); // The Loop if ( $query ->have_posts() ) { echo '<ul>'; while ( $query ->have_posts() ) { $query ->the_post(); echo '<li>' . ...


-2

before the slider //<?php $i = 0; ?> <section class="carouselItem <?php if($i == 0 ) : echo "active"; ?>"> //start loop here <section class="carouselItem <?php if($i == 0 ) : echo "active"; ?>"> </section> //$i++; end loop Hope this will solve your problem


0

Try this: $args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order'=> 'ASC', 'date_query' => array( array( 'after' => '30 days ago' ), ), ); $query = new WP_Query( $args ); You can't directly order by ...


0

Your question is incomplete and you have omitted all the context for some weird reason. I hope we agree that query_posts() is a bad idea. There's enough been said on it: When to use WP_query(), query_posts() and pre_get_posts Having said that, have you tried wp_reset_postdata, wp_reset_query or rewind_posts? I have no idea what you are doing here, but you ...


2

Try to change: <?php if ( have_posts() ) To <?php if ( $verhuurd_query->have_posts() )


1

The function have_posts is for the main loop, so the if statement is checking the main loop, which will probably always have posts. You want to use the custom query's have_posts for the if statement instead. if ( $verhuurd_query->have_posts() ) : while ( $verhuurd_query->have_posts() ) : $verhuurd_query->the_post(); ?>



Top 50 recent answers are included