minkowski
Forum Replies Created
-
Forum: Hacks
In reply to: shortcode_parse_atts() and PHP VersionsEdited.
Forum: Alpha/Beta/RC
In reply to: Admin Interface and Post TypesI’ve written menus like that in the past, and it’s very useful, but I don’t think I can apply this technique to altering menus that were already created. I did try Adding one like this and then setting the show_ui parameter to false in the register_post_type function but that just removes everything and I can’t access the page even via a direct link.
What I did find was a plugin called Admin Menu Editor that will do everything I need, but it’s still something that I would prefer to code in myself. I reckon I’m going to have to take the code apart in that plugin and see how they did it there.
Thanks for looking though!
Forum: Alpha/Beta/RC
In reply to: Admin Interface and Post TypesIn fact, I want it to look more like this.
- Taxonomy Name (link to wherever I like)
- View/Edit Post Type A
- Add Post Type A
- View/Edit Post Type B
- Add Post Type B
- View/Edit Taxonomy
There is another solution, but it means tinkering with the database itself.
In your WordPress database there is a table called wp_posts, if you view the content of the table by post_type you will see all of the nav_menu_items grouped together.
You just need to delete the right row from this table. Discerning the right row isn’t all that easy, however, but there are clues.
The menu_order field should have a value, so if you knew where it was on a particular menu that will help. Also, the post_content field for any custom taxonomies will probably be blank, so that could be in indicator too. The other values in the post_content field should have the content of a particular post and these are probably not causing the problem.
OK, there’s a few probablys and by no means am I suggesting that this is foolproof, but it’s better than deleting all of the database tables. It’s worked for me without problems and maybe it is an interim solution until this bug is fixed.
Forum: Alpha/Beta/RC
In reply to: Admin Interface and Post TypesI’ve just encountered this issue again. I just ignored it last time and had a stack of different post types in the admin menu, but if I can get it sorted this time I’ll be a lot happier with the result.
So, anyone know?
Forum: Themes and Templates
In reply to: Custom Post Types in Menu disappeared.Well colour me moronic!
OK, don’t know why, but before I didn’t have to enable them in the Screen Options menu, I don’t know why but I do now.
You know how you’re just staring so deeply into code that you miss what’s right in front of you? Yeah, well, that happened.
Forum: Themes and Templates
In reply to: Custom Post Types in Menu disappeared.More information. I don’t have any plugins installed. All the code is mine and was working before.
Forum: Alpha/Beta/RC
In reply to: Getting custom taxonomy linkAha, thanks very much! And quick too!
My final code for this is…
<ul> <?php $args = array('taxonomy' => 'news'); ?> <?php $tax_menu_items = get_categories( $args ); foreach ( $tax_menu_items as $tax_menu_item ):?> <li> <a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>"> <?php echo $tax_menu_item->name; ?> </a> </li> <?php endforeach; ?> </ul>
Forum: Alpha/Beta/RC
In reply to: Admin Interface and Post TypesIf I use the register_post_types function a new top level menu item is built for me automatically. This appears at the bottom of the top part of the menu beneath Comments by default.
If I try to make a new top level item in the top section of the menu manually, all I seem to be able to do is create a subpage to an existing type.
add_posts_page adds a new page beneath Posts, add_pages_page add a new page beneath Pages, etc.
The problem is that I want to place a new top level menu item within this top part of the menu manually so I can build in all of the subpages manually.
The problem I’m having is simply cosmetic to the admin interface as I just want to reorder things, I just don’t know how.
Forum: Alpha/Beta/RC
In reply to: Admin Interface and Post TypesNo, I can build the post types manually, it’s just a matter of organising the admin interface the way I’d like it. I may download the Custom Post Type UI plugin and dissect it but I really need to get my head around creating an admin interface.
Forum: Alpha/Beta/RC
In reply to: Admin Interface and Post TypesGiving this a little bump as I remember something.
I vaguely remember some documentation or an example of adding post types to WordPress earlier than 3.0 but I have had no luck finding it again.
I don’t remember the details of the code but it may help me solve thins problem. Does anyone know where that may have been?
Forum: Themes and Templates
In reply to: Which sidebar a widget is in?I did and I tried that, it only tells me if a sidebar has active widgets and doesn’t return any different response depending on which sidebar the widget is placed.
I’ve actually changed my tactic regarding this anyway. I was building an announcement system in a rather quick and hacky way and have changed it to a different quick and hacky way.
Still, would be interested to know if this is possible for the future.
Forum: Plugins
In reply to: Custom Query sorting by type?A further note, the ELSE 100 is superfluous if I limit my results to
AND (postmeta.meta_key = 'document' OR postmeta.meta_key = 'gallery' OR postmeta.meta_key = 'video' OR postmeta.meta_key = 'audio')
but you get the idea.
Also, I should probably make the key value combination at key = type & value = document, etc.
I can’t wait until different media types are sorted, will save me these headaches.
Forum: Plugins
In reply to: Custom Query sorting by type?And I seem to have the solution.
The complete WP-ised query is as follows.
$querystr = " SELECT posts.* FROM $wpdb->posts posts INNER JOIN $wpdb->term_relationships termrel ON posts.id = termrel.object_id INNER JOIN $wpdb->postmeta postmeta ON posts.id = postmeta.post_id INNER JOIN $wpdb->term_taxonomy termtax ON termrel.term_taxonomy_id = termtax.term_taxonomy_id INNER JOIN $wpdb->terms terms ON termtax.term_id = terms.term_id WHERE terms.term_id = $cat_ID AND posts.post_status = 'publish' AND (postmeta.meta_key = 'document' OR postmeta.meta_key = 'gallery' OR postmeta.meta_key = 'video' OR postmeta.meta_key = 'audio') ORDER BY (CASE postmeta.meta_key WHEN 'Document' THEN 1 WHEN 'Gallery' THEN 2 WHEN 'Video' THEN 3 WHEN 'Audio' THEN 4 ELSE 100 END) ASC ";
The important bit is clearly the ORDER BY (CASE… statement. It is quite self explanatory I think, the WHEN clause places the meta key in the order defined after the THEN and the ELSE 100 END simply places any other returned keys that are not defined at position 100 in the list, ie. last.
The last thing I need to do is grab the meta key in php and print it when it changes from one to another, except in the case of audio. Which is simple enough really.
Hope this helps someone in the future.
Forum: Plugins
In reply to: Custom Query sorting by type?What I have so far, in standard SQL is:
SELECT * FROM wp_posts INNER JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id INNER JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id INNER JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id WHERE wp_terms.slug = 'my-category-name' AND wp_posts.post_status = 'publish' AND (wp_postmeta.meta_key = 'document' OR wp_postmeta.meta_key = 'gallery' OR wp_postmeta.meta_key = 'video' OR wp_postmeta.meta_key = 'audio') ORDER BY wp_postmeta.meta_key ASC
From this I get results returned in the meta key order Audio, Document, Gallery and Video.
I can insert the <h2></h2> headings with php when the meta key changes, but I still need the order to have the Audio tag last of all.
I suppose, then, that unless someone has a brilliant solution that is built into WordPress queries that this is a SQL question.