Michael Fields
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: the_post_thumbnail replaced by default imageTry it like this:
<?php if ( has_post_thumbnail() ) the_post_thumbnail( 'single-post-thumbnail' ); else echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/default_thumb.jpg" alt="title" title="title" />'; ?>you might need to adjust the url to “default_thumb”. The example assumes that it is in the same directory as your themes main stylesheet.
Forum: Plugins
In reply to: What plugin could I use to make a communityI don’t think you would need a plugin to do this at all…. WordPress allows for multiple users and, if your settings are correct, anyone can register at example.com/wp-login.php. As for displaying content only to logged in users… this is a little trickier, but can be accomplished by using the current_user_can() function to hide specific pieces of content from non-logged-in users. I suggest something like this in your theme files:
<?php if( current_user_can( 'read' ) ) { /* Show special content */ } ?>Hope this helps,
-MikeForum: Fixing WordPress
In reply to: Display horizontal list of all categoriesJoe,
You can give this code a try. I know there’s a lot but I just had cup of coffee and can’t stop typing 🙂 Should work in any template file you place it in. The best part is you can replace the first argument passed to get_terms() to any taxonomy you wish displayed ie. ‘post-tags’, ‘categories’ or ‘my-custom-taxonomy’.Best wishes,
-Mike$category_links = array(); $categories = get_terms( 'category' ); if( !is_wp_error( $categories ) ) { foreach( $categories as $order => $category ) { $url = esc_url( get_category_link( $category->term_id ) ); $title = esc_attr( $category->name ); $text = esc_html( $category->name ); $category_links[] = "\n" . '<a href="' . $url . '" title="' . $title . '" >' . $text . '</a>'; } } $category_links_count = count( $category_links ); if( $category_links_count > 1 ) print 'Categories: ' . implode( ', ', $category_links ); else if( $category_links_count === 1 ) print 'Category: ' . $category_links_count[0];Forum: Plugins
In reply to: Plugin Development — Override theme CSSI would suggest that you get specific with the styles that you are using for your plugin css. For this example:
<div id="my_plugin_container"> <ul class="conversation"> <li>Hi There</li> <li>How are you doing</li> <li>Just fine, thank you very much</li> </ul> </div>Try using this css:
/* Reset everything inside your plugin's div */ #my_plugin_container *{ margin:0; padding:0; } /* To access the div */ #my_plugin_container{ } /* To access the list */ #my_plugin_container ul.container{ } /* To access the list items */ #my_plugin_container ul.container li{ }I’m not a css expert, but I hope this helps 🙂
Forum: Themes and Templates
In reply to: Applying an arbitrary template to a postI would recommend that you check out the Custom Post Template plugin.
Forum: Plugins
In reply to: [Plugin: Taxonomy Images BETA] Show image within single.php ?You can try this loop:
$cats = get_categories(); foreach ( $cats as $c ) { $url = get_category_link( $c->term_id ); $img = $taxonomy_images_plugin->get_image_html( 'detail', $c->term_taxonomy_id ); if( !empty( $img ) ) print '<a href="' . $url . '">' . $img . '</a>'; }If you want to use a different taxonomy, you can replace get_categories() with get_object_terms(). Something like this may work:
$object_terms = wp_get_object_terms( $post->ID, 'fish' );Forum: Plugins
In reply to: [Plugin: Taxonomy Images BETA] Show image within single.php ?Thanks for the plugin, it was exactly what I was looking for !
No Problem! I really wanted it for my site too! Glad you like it.
I’d like to show the image within single.php. I guess I should also be able to choose which taxonomy is involved…
If you are using version 0.3 you should be able to use the get_image_html() method to display images in single views. It takes two arguments: the first is the size of the image and the second is the term_taxonomy_id of the image. Please bear in mind that this is different than the term_id.
To return the image link:
$my_var = $taxonomy_images_plugin->get_image_html( 'detail', $c->term_taxonomy_id );To print the image link:
$taxonomy_images_plugin->print_image_html( 'detail', $c->term_taxonomy_id );Hope this helps,
-MikeForum: Plugins
In reply to: [Plugin: Taxonomy Images BETA] Not compatible with Reveal IDs for WP AdminNo problem! Thanks for informing me of the incompatibility!
Forum: Plugins
In reply to: [Plugin: Taxonomy Images BETA] Not compatible with Reveal IDs for WP Adminkahi,
I was able to find a work around to a couple of bugs that I discovered in the Reveal IDs for WP Admin plugin. Thanks for the tip! It was a super easy fix.Please note that this plugin stores an array that use the $term->term_taxonomy_id as the key and the $post->ID of the attachment as it’s value. Although $term->term_id will work in some cases, it can return a false positive where multiple taxonomies share the same name.
I added a argument to get_image_html() and print_image_html() which will allow you to pass the term_taxonomy_id to specify which image you would like returned. You second example would look something like this:
$cats = get_categories(); foreach ( $cats as $c ) { $url = get_category_link( $c->term_id ); $img = $taxonomy_images_plugin->get_image_html( 'medium', $c->term_taxonomy_id ); if( !empty( $img ) ) print '<a href="' . $url . '">' . $img . '</a>'; }Before you upgrade to 0.3, MAKE SURE TO DELETE LINE 75:
<?php do_action( 'taxonomy_image_plugin_print_image_html', 'detail' ); ?>Forum: Plugins
In reply to: [Plugin: Taxonomy Images BETA] Not compatible with Reveal IDs for WP Adminkahi – Thanks for the feedback – I will look into the compatibility issue in the next couple of days. I have absolutely no problem with making the settings var public. I used the $wp_query in the action becuse it was the only way (that I could find) to get the term_taxonomy_id on all suported views. If you know a better way, I would love to know!
Forum: Fixing WordPress
In reply to: One category on Home page, all else on Blog pageVery strange. Are you sure that you are adding the code to page.php and not index.php? Also does your theme have a home.php file? If so, try to temporarily rename it to __home.php. That file is sneaky and can sometimes cause unintended headaches. Best of luck.
Forum: Fixing WordPress
In reply to: One category on Home page, all else on Blog pageI’m using WordPress as CMS
I think that it’s safe to say that we are all using wordpress as a CMS.
I am wondering if it is possible to set only one category to show on my Home page and all the other ones on my Blog page. I’m using WordPress as CMS, and configured it to display my home page as Home and the posts page as Blog.
Yes this is possible. You will want to add the following code to your theme’s page.php file:
<?php $front_page_category = get_posts( 'category=14' ); if( is_front_page() && $front_page_category ) { foreach( $front_page_category as $post ) { setup_postdata( $post ); /* do loop stuff here */ } } ?>You should change the value of “category” in the
query_posts()function to the category id that you wish to have displayed.Forum: Fixing WordPress
In reply to: 404 on custom ( non-wordpress ) pagesMECU, no problem, glad it worked for you 🙂
Forum: Fixing WordPress
In reply to: How do I change Password Protected text?@electric Studio – what an awesome thing to say and I totally agree! I would be lost in web development without help from numerous support forums that I have been a part of… always nice to hear that my efforts are appreciated 🙂
@geoff – glad this worked for you and congrats on your first block of php code!
Forum: Themes and Templates
In reply to: explode function not working in wordpress loopTotally agree with alchymyth – that’s the part that confused my server as well.