shagdirty
Forum Replies Created
-
Forum: Hacks
In reply to: Custom post type, prevent new post & post deletionBump! Anybody have thoughts on this. I have a similar need. I have custom posts that are created/deleted through an external system and pulled into wordpress. Thus any user role (whether Subscriber or Admin) should not be able to delete or add a custom post type entry through the WP system. They will need to edit some info via WP.
Forum: Fixing WordPress
In reply to: Displaying a List of Custom Menus in Custom Meta BoxI ended up figuring out a way to get this accomplished for those who may be curious. I’m not sure if this is the most efficient way to do it or not but it works…
function makeMyMenus() { $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); global $menuArray; $menuArray = array('select a sub menu'); foreach ( $menus as $menu ) { $menuArray[] = $menu->name; } } makeMyMenus(); // Adding sub menu drop down to pages. $meta_boxes[] = array( 'id' => 'sub_menu', 'title' => 'Sub Menu', 'pages' => array('page'), // applicable post types 'context' => 'side', 'priority' => 'low', 'fields' => array( array( 'name' => 'Sub Menu', 'desc' => 'The sub menu for this page created via Appearance > Menus', 'id' => 'custom_menu', 'type' => 'select', 'options' => $menuArray ) ) );
Use it on the front-end something like this…
if( get_post_meta($post->ID, 'custom_menu', true) == true ) { $menuName = get_post_meta($post->ID, 'custom_menu', true); } wp_nav_menu( array('menu' => $menuName));
Forum: Fixing WordPress
In reply to: using a dynamic array with query_posts and post__inActually I think I’ve found the solution via a search…
if(empty($horse_var)){ echo "horse_var is false"; }else{ echo "horse_var is true"; }
I’ll probably just wrap my whole query in this logic which should do the trick, albeit in a less than efficient fashion I’m sure.
Rebuttal anyone?
Forum: Fixing WordPress
In reply to: using a dynamic array with query_posts and post__inWOOOOO! (in my Nature Boy Rick Flair voice). Worked like a charm! Thanks a million. Arrays become slightly less mystified to me.
This raises another question, (perhaps for another post but since I have the attention of a savvy individual) If there’s nothing within post__in, query_posts returns everything I guess? that’s what my initial test shows me anyway. Is there a way around that off the top of your head? So if an array is empty will it return false so I can use some conditional logic or something?
if $horse_var { // spit out the array in a different var maybe? } else { // nothing in the array so show a default post ID maybe??? }
Just so you know, $horse_var comes from here…
$horse_var = get_the_author_meta( 'horses', $current_user->ID );
So basically if the current user has horses associated with it, display those horses. If the current user has NO horses, I don’t want them to see ALL the horses. Clear as mud?
thanks
Forum: Fixing WordPress
In reply to: using a dynamic array with query_posts and post__inJust tried using $horse_var in place of $horse_array but to no avail. If I do that, I get nothing back, not even the last item in the array. I get this when I dump horse_var:
array(3) { [0]=> string(3) "546" [1]=> string(3) "540" [2]=> string(3) "550" }
My logic (as ignorant and flawed as it may be) was to try and echo a string of post ID numbers. if I echo $horse_var I just get “Array” so I didn’t think that would work. I’m terrible with arrays so I’ve struggled pretty hard just to get to this point!
Forum: Fixing WordPress
In reply to: adding custom data to admin pagesAfter a bit more Googling, I found this tutorial from Justin Tadlock about Adding and using custom user profile fields. Uses the hooks above but spells it out for coding-challenged folks like me.
Forum: Fixing WordPress
In reply to: adding custom data to admin pagesexcellent. thanks very much Rich. I’m sure that will get me started. More questions to come…
Forum: Fixing WordPress
In reply to: AJAX post pagination within shadowbox/lightboxI was grossly overthinking this. I ended up creating a template and a page (so I had something to link to) that used that template and opening that url within shadowbox. All of the standard WP functions and loop work just fine, including the next/prev links. excellent
Forum: Fixing WordPress
In reply to: list the top-most parent page of a sub pageman, THANKS! that is exactly what I needed. worked like a charm.
Forum: Fixing WordPress
In reply to: display info of user with certain role or level ini WP 2.7I know this is an old post but…
@jim de Groot’s last code block is perfect for what I’m trying to do but I’d also like to display any posts by the filtered users as well. So, if a user has a specific custom role assigned, display his or her last X number of posts. I’ve done some digging but to no avail. I’m not great with php so any help would be appreciated.
thanks, Shag
Forum: Themes and Templates
In reply to: Different template per pageI just had this issue however it was because I had renamed style.css. Must be css controlling something about that. possibly visibility? Didn’t do any more research into it.