erikw46
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Custom Field – Media Uploader – Radio ButtonsI figured out the code if anyone is interested:
function be_attachment_field_credit( $form_fields, $post ) { $form_fields['be-photographer-name'] = array( 'label' => 'Orientation', 'input' => 'html', 'value' => get_post_meta( $post->ID, 'be_photographer_name', true ), 'html' => "<input type='radio' name='attachments[{$post->ID}][be-photographer-name]' value='op1'> Option 1   <input type='radio' name='attachments[{$post->ID}][be-photographer-name]' value='op2'> Option 2   <input type='radio' name='attachments[{$post->ID}][be-photographer-name]' value='op3'> Option 3", ); $form_fields['be-photo-location'] = array( 'label' => 'Location', 'input' => 'text', 'value' => get_post_meta( $post->ID, 'be_photo_location', true ), 'helps' => 'Where was this photo taken?', ); return $form_fields; } add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );Now I am trying to work out this piece of code. I want to take the values from that radio button and use them as css classes for images inserted into my blog posts.
I have replaced the code that surrounds the attached images with this in my functions.php file:
function html5_insert_image($html, $id, $caption, $title, $align, $url) { $url = wp_get_attachment_url($id); $html5 = "<figure>"; $html5 .= "<img src='$url' alt='$title' />"; if ($caption) { $html5 .= "<figcaption>$caption</figcaption>"; } $html5 .= "</figure>"; return $html5; } add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );I want to add the class to the <figure> element. I am messing around with this but having no luck:
$html5 = "<figure class='$attachment['be-photographer-name']';"It gives me this error, Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING.
Any help would be awesome!
Forum: Fixing WordPress
In reply to: Returning Multiple Meta Data ValuesYes, my fault. Here is the code. The data would be entered as a class on the <img> tag.
Thank you.
<?php get_header(); ?> <section id="content-container"> <?php $loop = new WP_Query( array( 'post_type' => 'photos', 'posts_per_page' => 10 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="photo-container"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><img class="entry-photo <?php echo get_post_meta($post->ID, 'field', true); ?>" src="<?php bloginfo('template_url'); ?>/images/photos/<?php echo get_post_meta($post->ID, 'photoname', true); ?>"></a> <span class="entry-title"><?php the_title( '<a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a>' ); ?> | <?php the_time('F jS, Y'); ?> </div><!-- end .photo-container --> <?php endwhile; ?> </section><!-- end #content-container --> <?php get_footer(); ?>Forum: Fixing WordPress
In reply to: Custom Posts Working with Custom Write Panels?Just found this post while searching the forums for something similar… Im sure you have solved it yet but just in case…
change this code:
if( function_exists( 'add_meta_box' ) ) { add_meta_box( 'new-meta-boxes', ucfirst( $key ) . ' Custom Post Options', 'display_meta_box', 'post', 'normal', 'high' ); } }to this:
if( function_exists( 'add_meta_box' ) ) { add_meta_box( 'new-meta-boxes', ucfirst( $key ) . ' Custom Post Options', 'display_meta_box', '***customPosttitle***', 'normal', 'high' ); } }Replace ***customPosttitle*** with title you gave your custom post
Forum: Themes and Templates
In reply to: Link to page only of a category existsI feel like I am getting closer but its still not there:
function servicesList(){ $args = array( 'orderby' => 'id', 'order' => 'ASC', 'child_of' => 8, 'hide_empty' => 0 ); $categories = get_categories($args); foreach($categories as $category) { if ( empty($category) ) echo '<li>' . $category->name.'</li> '; else echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </li> ';} }Perhaps I have to use
"explode();"somewhere?Forum: Themes and Templates
In reply to: Link to page only of a category existsSo I realized that I was going about this all wrong. Here is my new function:
function servicesList(){ $args = array( 'orderby' => 'id', 'order' => 'ASC', 'child_of' => 8, 'hide_empty' => 0 ); $categories = get_categories($args); foreach($categories as $category) { echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </li> '; } }Now what I am trying to figure out is if a category is empty, for the function to echo
<li>' . $category->name.'</li>instead of
<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </li>. Any help would be appreciated. Thanks.Forum: Fixing WordPress
In reply to: Displaying Subpages in listsSo after some more research I am wondering if this code can be modified to do what I want.
<?php $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0'); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>What I would like to be able to do is show the subpages of a certain page instead of the current page that I am on. I am guessing that I need to replace “.post->ID.'” with the ID number of the parent page whos subpages I want to display.
Any ideas how to get this to work?
Thanks,
ErikForum: Fixing WordPress
In reply to: Displaying Subpages in listsAs I do more research into this I think it is also important to note that I would like to display the sub-pages of “Services” on the home page, and the sub-pages of “Clients” on the clients page. These lists will not appear on the Parent Page.
I am using the above page hierarchy structure so that it is easy for my client to understand where to put the new pages he creates.
Forum: Themes and Templates
In reply to: child page not displaying correctlyI figured out my problem. On child pages any links to images or style sheets have to be absolute links and not relative. So I am guessing that it is probably good practice to use absolute links whenever working in WP.
Forum: Themes and Templates
In reply to: child page not displaying correctlyHere is a link to one of the subpages with the problem. http://www.klmarcom.com/portfolio/jd-rose-and-company
As you can see the logo image at the top is a broken image and the form at the bottom isn’t styled correctly by CSS as it is on the main pages.
Thanks.
Forum: Fixing WordPress
In reply to: Include div with content from another pageyah its a static page. i have multiple areas on the page where the content can be edited though because i am using the secondary html plugin. all i want is to copy the rightColumn div, not the whole page, and place that as the rightColumn on a different page.
never used Iframes before, and after some google searching i am still confused as to how to get it to work.
Forum: Fixing WordPress
In reply to: Show only posts who’s tags match page nameI really appreciate you helping me out with this. Still no luck, I am probably just doing some stupid mistake with the code. I have been teaching wordpress to myself so there are some gaps in my knowledge.
Here is the link to the pastebin: http://wordpress.pastebin.com/h1Wx8Rn2
Thank you so much.
Forum: Fixing WordPress
In reply to: Show only posts who’s tags match page nameThanks for your help!
You are correct about what I am trying to achieve. However I tried getting that code you supplied to work and was having no luck. I believe (but I could be wrong) that in the last set if parenthesis you are missing a quotation mark however even after fixing that I was still having no luck. All I get is the title of the page displaying instead of the posts that have a tag which is the same title as the page.