Ask your WordPress questions! Pay money and get answers fast! (more info)

Attachments Image and description in archive WordPress

I need to have the attachment image (medium), the attachment url and the first 100 characters of the description of each image attachment displayed on the archives page.

This is for this blog:
http://2filles2villes.com/category/favorites/

The idea is that the two images are side by side with the image description (first 100 characters) below the image linking to the image attachment page.

I am not a coder, so I really need to have cut'n paste code that I can add to the loop.

Thanks



==========================
More detail based on comments below:

The archive code is:


<?php
/**
* The template for displaying Archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package Advantage
* @since Advantage 1.0
*/

get_header(); ?>


<div class="content-area grid-wrapper">




<div class="site-content g <?php
echo Pure::if_enabled( "blog_sidebar", "two-thirds" );
echo " "; // Echo space not to mess up spacing in HTML
echo Pure::get_theme_mod( "content_position", null )
?>" role="main">

<?php if ( have_posts() ) : ?>

<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( "cf" ); ?>>

<?php get_template_part( 'parts/header', get_post_format() ); ?>
<?php get_template_part( 'parts/content', get_post_format() ); ?>

</article><!-- #post-<?php the_ID(); ?> -->
<?php endwhile; ?>

<?php pure_pagination() ?>

<?php else : ?>

<?php get_template_part( 'no-results', 'index' ); ?>

<?php endif; ?>

</div><!-- #content .site-content -->

<?php
if ( Pure::is_enabled( "blog_sidebar", false ) ) {
get_sidebar();
}
?>


</div><!-- #primary .content-area -->
<?php get_footer(); ?>



The file that is called <?php get_template_part( 'parts/content', get_post_format() ); ?> is:

<?php
/**
* @package Advantage
* @since Advantage 1.0
*/
global $more;
$more = 0;
?>
<?php if ( is_search() ) : // Only display Excerpts for Search ?>

<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->


<?php else : // Display Content ?>
<div class="entry-content">



<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'puremellow' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links">', 'after' => '</div>' ) ); ?>



</div><!-- .entry-content -->

<?php endif; ?>

Answers (3)

2013-04-06

juan manuel incaurgarat answers:

I can do it for you. Email me to [email protected] please :) I can start right now


tk10 comments:

can you post it here??

2013-04-06

Daniel Yoen answers:

hello,

could you please upload archive.php files in theme folder ?

:-)


Daniel Yoen comments:

I think code is not there, please upload another "parts/content" that referring to post format, or you use shortcode(maybe from plugin) in post content ?. :-)


Daniel Yoen comments:

Also, could you mentioned the theme you use? :-)


tk10 comments:


<?php

/**

* @package Advantage

* @since Advantage 1.0

*/

global $more;

$more = 0;

?>

<?php if ( is_search() ) : // Only display Excerpts for Search ?>



<div class="entry-summary">

<?php the_excerpt(); ?>

</div><!-- .entry-summary -->





<?php else : // Display Content ?>

<div class="entry-content">







<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'puremellow' ) ); ?>

<?php wp_link_pages( array( 'before' => '<div class="page-links">', 'after' => '</div>' ) ); ?>







</div><!-- .entry-content -->



<?php endif; ?>


tk10 comments:

the them is a paid theme:

[[LINK href="https://creativemarket.com/PureMellow/3366-Advantage-Creative-Portfolio-Theme"]][[/LINK]]


tk10 comments:

https://creativemarket.com/PureMellow/3366-Advantage-Creative-Portfolio-Theme


Daniel Yoen comments:

Sorry, you use custom uploader to upload images ?, plase screenshot editor page. Because, wordpress is very customisable, there are so many ways to display a post, and usually different for each theme, we need more specific. :-)

Thank you before


tk10 comments:

no, no custom uploader, I use the default WP uploader.
I use the default attachment url and the description on the image (all default WP)


Daniel Yoen comments:

Try this, put this line on functions.php :

add_filter('image_send_to_editor', 'node_insert_images', 10, 7);
function node_insert_images($html, $id, $alt, $title, $align, $url, $size)
{
$image = wp_get_attachment_image_src($id, $size);
$desc = substr(get_post($id)->post_content, 0, 100);
$atturl = get_attachment_link( $id );

$alt = get_post_meta($id, '_wp_attachment_image_alt', true);

$custom = '<a href="' . $atturl . '"><img src="' . $image[0] . '" alt="' . $alt . '" width="' . $image[1] . '" height="' . $image[2] . '" class="align-' . $align . ' ' . $size . ' wp-image-' . $id . '" /><span class="description">' . $desc . '</span></a>';

return $custom;

}


remove media from content editor, then add media

hope this help :-)

2013-04-06

Abdelhadi Touil answers:

Hi.
We need to take a look at archive.php file in your wordpress theme.
If you can send me your theme then I can make changes for you and resend you the theme.
Good luck.


Abdelhadi Touil comments:

As I see from the "content" part code, the excerpts is displayed for search archive, so I'v deleted the "if statment" to display excerpts on normal archive, then the "content" part code will be:

<?php
/**
* @package Advantage
* @since Advantage 1.0
*/
global $more;
$more = 0;
?>

<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->

<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'puremellow' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links">', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->


please make a backup of your theme before trying the above code.
Good luck.