Posts by webdesignerart

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Is ‘custom_image’ the key of the meta? You’re code isn’t clear… why are you saving attachments into the custom fields? Parker

Dude i done work like charm but i think its bad 2 time looops can you check, ALthough what i want this code does.


<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); 

if( $image_upload_id = get_post_meta($post->ID, $field['custom_image'], true)){
    $image_upload_id = get_post_meta($post->ID, $field['custom_image'], true);
    $img = $image_upload_id ['custom_image'][0];
    echo wp_get_attachment_image($img, 'full'); 
}

 endwhile; endif; ?>

But in this page again i m using loop:


<?php
if( have_posts() ) {
  while( have_posts() ) {
    the_post();
    ?>

<?php the_content(); ?>

so what you think is fine, Two loops in page.

Because i can’t retrieve image without loop that’s why i use two loops.

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Is ‘custom_image’ the key of the meta? You’re code isn’t clear… why are you saving attachments into the custom fields? Parker
custom_image is ID.
// Default metabox for custom post types.
function avz_custom_meta_box() {

   // $post_types = get_post_types( array( 'public' => true ) );
   $post_types = get_post_types();
    foreach ( $post_types as $post_type ) {
        if ( $post_type == 'page' || $post_type =='post' )
            continue;
        add_meta_box(
        'custom_image', 
        'Header Image Upload Box', 
        'show_avz_custom_meta_box', 
        $post_type, 
        'normal', 
        'high' );
    }

}
add_action('add_meta_boxes', 'avz_custom_meta_box');
1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Hi Guys i found some solution but i shows all images upload in post but i want to show only image from my meta box that i upload.

working code example but shows all image upload .


    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { echo ‘
  • ’; echo wp_get_attachment_image( $attachment->ID, ‘full’ ); echo ‘

    ’; echo apply_filters( ‘the_title’, $attachment->post_title ); echo ‘

  • ’; } } endwhile; endif; ?>
this code in not working but in this code you will get my custom post type meta box id:
if( $image_upload_id = get_post_meta($post->ID, $field['custom_image'], true)){
    $image_upload_id = get_post_meta($post->ID, $field['custom_image'], true);
    $img = $image_upload_id ['custom_image'][0];
    echo wp_get_attachment_image($img, 'full'); 
}

So friend i want to show image which i upload through custom meta box.

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Guys i need help.

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Is the Theme supporting Custom Fields?

I just only add this code and in admin Custom Post Type showing the image upload form when i upload the image it shows in custom meta box area. But i can’t retrieve in post page. :(

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Hi Guys i am in problem can’t echo my attached image in custom post type please check. the code in functions.php


$prefix = 'custom_';
    $custom_meta_fields = array(

        array(
            //'label'   => 'Textarea',
            'desc'  => 'A description for the field.',
            'id'    => $prefix.'textarea',
            'type'  => 'textarea'
        )
    );

    // Default metabox for custom post types.
    function avz_custom_meta_box() {

       // $post_types = get_post_types( array( 'public' => true ) );
       $post_types = get_post_types();
        foreach ( $post_types as $post_type ) {
            if ( $post_type == 'page' || $post_type =='post' )
                continue;
            add_meta_box(
            $prefix.'image', 
            'Header Image Upload Box', 
            'show_avz_custom_meta_box', 
            $post_type, 
            'normal', 
            'high' );
        }

    }
    add_action('add_meta_boxes', 'avz_custom_meta_box');

        enter code here

    function show_avz_custom_meta_box() {
        global $avz_custom_meta_box_fields, $post;
        // Use nonce for verification
        echo '';

        // Begin the field table and loop
        echo '';
        foreach ($avz_custom_meta_box_fields as $field) {
            // get value of this field if it exists for this post
            $meta = get_post_meta($post->ID, $field['id'], true);
            // begin a table row with
            echo '
                    ';
                    switch($field['type']) {
                        case 'image':
                            $image = get_template_directory_uri().'/images/image.png';  
                            echo ''.$image.'';
                            if ($meta) { $image = wp_get_attachment_image_src($meta, 'medium'); $image = $image[0]; }               
                            echo    '

                                             Remove Image
                                            '.$field['desc'].'';
                        break;

                    } //end switch
            echo '';
        } // end foreach
        echo ''; // end table
    }

    // Save the Data

    function save_multiBox_custom_meta($post_id) {
        global $avz_custom_meta_box_fields;

        // verify nonce
        if (!wp_verify_nonce($_POST['avz_custom_meta_box_fields_nonce'], basename(__FILE__))) 
            return $post_id;
        // check autosave
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
            return $post_id;
        // check permissions
        if ('page' == $_POST['post_type']) {
            if (!current_user_can('edit_page', $post_id))
                return $post_id;
            } elseif (!current_user_can('edit_post', $post_id)) {
                return $post_id;
        }

        // loop through fields and save the data
        foreach ($avz_custom_meta_box_fields as $field) {
            if($field['type'] == 'tax_select') continue;
            $old = get_post_meta($post_id, $field['id'], true);
            $new = $_POST[$field['id']];
            if ($new && $new != $old) {
                update_post_meta($post_id, $field['id'], $new);
            } elseif ('' == $new && $old) {
                delete_post_meta($post_id, $field['id'], $old);
            }
        } // enf foreach

        // save taxonomies
        $post = get_post($post_id);
        $category = $_POST['category'];
        wp_set_object_terms( $post_id, $category, 'category' );
    }
    add_action('save_post', 'save_multiBox_custom_meta');

And in single.php


if( $image_upload_id = get_post_meta($post->ID, $field['custom_image'], true)){
    $img = $image_upload_id ['custom_image'][0];
    echo wp_get_attachment_image($img, 'full'); 
}

But can’t find attached image. In admin uploaded image show but in post page not showing. Guys help me. i know i am doing mistakes and bad coding. :(

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Guys Got solution :)

    //    $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );

$classes[] = 'menu-item-' . $item->ID;

        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
         $class_names = ' class="' . esc_attr( $class_names ) . '"';

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Why this code not including properly :(

1547 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Hi Guys,

I want to add description + item class name to li, I use walker class it add the description of of item but add the class of item, Please help.

class My_Walker extends Walker_Nav_Menu
{
    function start_el(&$output, $item, $depth, $args) {
        global $wp_query;
        $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
        $class_names = $value = '';
        $classes = empty( $item->classes ) ? array() : (array) $item->classes;
        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
        $class_names = '';
        $output .= $indent . '
  • ’; $attributes = ! empty( $item->attr_title ) ? ’ title=”’ . esc_attr( $item->attr_title ) .’”’ : ’’; $attributes .= ! empty( $item->target ) ? ’ target=”’ . esc_attr( $item->target ) .’”’ : ’’; $attributes .= ! empty( $item->xfn ) ? ’ rel=”’ . esc_attr( $item->xfn ) .’”’ : ’’; $attributes .= ! empty( $item->url ) ? ’ href=”’ . esc_attr( $item->url ) .’”’ : ’’; $item_output = $args->before; $item_output .= ‘’; $item_output .= $args->link_before . apply_filters( ‘the_title’, $item->title, $item->ID ) . $args->link_after; $item_output .= ‘ ’ . $item->description . ‘ ’; $item_output .= ‘’; $item_output .= $args->after; $output .= apply_filters( ‘walker_nav_menu_start_el’, $item_output, $item, $depth, $args ); } }
  • 1547 posts
    • Has been part of the Envato Community for over 3 years
    • Has been a beta tester for an Envato feature
    • Has collected 10+ items on Envato Market
    • Sells items exclusively on Envato Market
    webdesignerart says

    Webdesignart has one going. Does anyone know of sites that were built using Daily Press? I can’t find any, though I don’t quite know how to do that kind of search.
    There is many people using dailypress theme :) you will found easily.
    by
    by
    by
    by
    by
    by