Wrap every four posts within a div [duplicate]

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() ): ?> <?php $counter = 0; while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php if ($counter % 4 == 0 && $counter != … Read more

Use BuddyPress data in loop (mkdir)

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 … Read more

Display subcategories in dropdown

You can use a similar block of code to display the categories in a dropdown. I have picked the following example from WordPress codex article on get_categories(): <select name=”event-dropdown” onchange=”document.location.href=this.options[this.selectedIndex].value;”> <option value=””><?php echo esc_attr(__(‘Select Event’)); ?></option> <?php $categories = get_categories(‘child_of=10’); foreach ($categories as $category) { $option = ‘<option value=”/category/blog/’.$category->category_nicename.'”>’; $option .= $category->cat_name; $option .= ‘ … Read more

How to display 3 post per slide

There are two popular solutions for this. You can: Alternative 1: Add a counter to the while, and do something special if the counter reaches 3: $i = 0; while(…) { $i++; if ($i == 3) { … $i = 0; } } This is difficult to do here because you will probably end up … Read more

WordPress call post-ID in jquery

This question is more of a js/jQuery is then WordPress. I am not going to post a working answer as It is hard to read the html given. And I think how you are doing it is not a effective solution. My answer should guide you towards better solution. First of all you do not … Read more

WordPress get post thumbnail url

Initially, I saw the double and single quotes all jumbled up. This did fix some of what I saw, but I finally had time to test the code you put up. First step, I used var_dump on $recent_posts to make sure I was getting the usable values. Next, I echoed each variable as it was … Read more