• Resolved carlabaldwin

    (@carlabaldwin)


    Hi Dan,
    Your plugin works great out of the box. I would like to add a link back to the parent post for each attached document or image. You say in your documentation to edit output, use the following:

    $doc_icon = apply_filters( ‘dg_icon_template’, $doc_icon, $this->gallery->useDescriptions(), $this->ID );

    I have the code for grabbing the post ID based on the attachment ID. I have the following in my child theme functions file, but it is not working:

    add_filter( ‘custom_doc_library’, ‘dg_icon_template’);
    function custom_doc_library($desc, $attachID ){

    $parent_id = $attachID->post_parent;
    echo “Parent ID: ” . $parent_id;
    }

    thank you for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter carlabaldwin

    (@carlabaldwin)

    I figured it out. For anyone else wondering…

    add_filter( ‘dg_icon_template’, ‘custom_doc_library’, 10, 3 );
    function custom_doc_library($doc_icon, $desc, $attachID ){

    if ( in_the_loop() ) {
    global $post;
    $parent_id = wp_get_post_parent_id( $attachID );
    $doc_icon = $doc_icon . ‘<br>attach ID: ‘ . $attachID . ‘<br>parent ID: ‘ . $parent_id;
    }
    return $doc_icon;
    }

    Plugin Author Dan Rossiter

    (@danrossiter)

    Glad you figured it out and sorry for the delayed reply! Been a crazy few months…

    -Dan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customize document icon with dg_icon_template filter’ is closed to new replies.