monkeybrain
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeIt works, oh dear, that’s great! Here the solution for everyone else, just edit $post_type, $tax, $tax_terms, etc.. and the loop outputs custom post type data without having to change the actual syntax. Less to think about, less to worry about, easily adaptable. Hurray!
<?php // for a given post type, return all $post_type = 'menu'; $tax = 'categories'; $tax_terms = get_terms($tax, array('orderby' => 'id', 'order' => 'ASC', )); if ($tax_terms) { foreach ($tax_terms as $tax_term) { $args = array( 'post_type' => $post_type, "$tax" => $tax_term->slug, 'post_status' => 'publish', 'posts_per_page' => - 1, 'orderby' => 'title', 'order' => 'ASC', 'caller_get_posts' => 1 ); // END $args $my_query = null; $my_query = new WP_Query($args); if ($my_query->have_posts()) { echo '<h3>' . $tax_term->name . '</h3>'; while ($my_query->have_posts()) : $my_query->the_post(); ?> // whatever you want in the loop <?php the_post_thumbnail(); ?> <?php echo esc_html( get_post_meta( get_the_ID(), 'menu_price', true ) ); ?> <?php the_title(); ?> <?php the_content(); ?> <?php endwhile; } // END if have_posts loop wp_reset_query(); } // END foreach $tax_terms } // END if $tax_terms ?>Thanks a lot for your help beirdostudio and deepbevel!
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeActually, the first link you posted http://stackoverflow.com/questions/10506505/wordpress-getting-posts-by-custom-post-type-and-category-with-each-category-a seems to work better than the solution from CookiesForDevo. I’ll try and get all the custom fields in there now and will report back if it works. 🙂
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeThanks for trying, but it just doesn’t make sense to use this syntax. There must be a way to keep it simple and make it work with default WordPress tags. Isn’t it just a matter of getting the right data into
the_post()?
If it’s doable with ordinary WordPress posts, why should it be that much more complicated with custom post types?Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeHaha, gotta love me some cookies too.
Unfortunately the way he solves it makes it rather difficult to work with the default WordPress tags like
<?php if ( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail(’33width’); ?>
<?php } ?>
I will try to adapt his solution tomorrow, maybe I can get it working. I don’t think usingecho $p->makes a lot of sense for thumbnails and custom fields, etc…Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeThanks! That works! Now I only have to adapt it so it works with all the custom fields and thumbnail images. I will look into that tomorrow. Again, thanks a lot!
Forum: Fixing WordPress
In reply to: Styling postsPosting a link to your site or a demo of the template would be help.
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeYes! The name of the category as a title, and below the list of all entries within that category. Then the next category title and below the according entries. Etc…
The php example I posted only uses a link to the menu item (it works for normal WordPress posts but not custom post types yet), but once the right data is in the query, I’ll list thumbnail, title, content, and additional custom fields like price and other details.
Forum: Fixing WordPress
In reply to: Post images contain borders – don't wantI just had a look, and I don’t see any grey borders around images and border is set to none. Maybe you just have to refresh your browser cache. http://www.refreshyourcache.com
Forum: Fixing WordPress
In reply to: Parts of image is cutting offThat seems not to be a CSS issue. It looks like the image is cropped differently on the new site. http://jerpat.org/afrihatsfashions/wp-content/uploads/2015/12/IMG0116-1-555×688.jpg
Maybe the new theme allows you to set the image dimensions somewhere?
Forum: Fixing WordPress
In reply to: RSS ErrorThe RSS feed URL http://www.themuse.com/feeds/rss works fine for me.
Forum: Fixing WordPress
In reply to: Menu link not working correctlyI just tried, and http://www.baslowsportsfield.org.uk/tennis/ works for me. Maybe it was just a temporary error?
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeThanks for your optimism 🙂 I also think this should be solvable, normal posts and custom post types can’t be that different, can they?
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeThanks @deepbevel, I try to not use too many plugins, so if it’s solvable without, that would be my preferred solution.
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeThanks! But that returns a syntax error on the last line of the template file, which is just a <?php get_template_part( ‘parts/html-footer’); ?>
Sorry, I also deleted the } … but after fixing it, it still returns the same list of menu links like on the screenshot.
Forum: Fixing WordPress
In reply to: List posts for each taxonomy/tag of a custom post typeThanks. Now the syntax errors are gone. But the code returns the name of the first
.$cat->name.and then an never ending list with linktext “Menu” and link to the current page. https://imgur.com/F17B4JiHere is the code used to create the custom post type http://pastebin.com/8pbniM3K
The menu items are then displayed on a custom page templateTemplate Name: Menu Overview