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

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 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

make get_post work in the loop

If you are using setup_postdata( $post ) you need to use the global $post as for some reason it does not work without that specific variable. Once you manually set $post to a new value, you are altering the $post global, so you will need to reset it back to the current post of the … Read more

Get_template_part() problem with the_content()

The problem is that you are running a loop from secondary query in front-page.php and the loop from main in page-home.php. So, the post data in page-home.php won’t be the data from the WP_Query in front-page.php. Additionally, you are trygin to get full template files as template parts, which is not correct. I mean, front-page.php … Read more

Category ID returns as ‘0’?

Answered my own question, although not exactly how I had originally intended. <?php $cat_name = get_theme_mod( ‘cat_1’ ); $cat_name = str_replace(‘ ‘,’-‘,$cat_name); ?> <?php query_posts(‘category_name=” . $cat_name); ?> So instead of trying to convert the category name to the category id, this seems to convert the category name to the category slug. I can test … Read more

Run “the loop” in a random order

As I understood, you want the same results but randomize their order. So, you need to shuffle that results. That is quite simple using shuflle() PHP function. But that function needs arrays, not objects. You could convert the object from WP_Query to an array or, I think better, use get_posts() instead of WP_Query. $args = … Read more

Filter existing hook using parameter and foreach loop

As per the suggestion of Milo who pointed me to the right direction, this problem has now been resolved. All I had to do was this… add_action( ‘init’, ‘get_custom_tax’ ); function get_custom_tax() { $args = array( ‘public’ => true, ‘_builtin’ => false ); $taxonomies = get_taxonomies( $args, ‘names’, ‘and’ ); foreach($taxonomies as $key => $taxonomy) … Read more