WordPress.org

Ready to get started?Download WordPress

Forums

Inserting images ant other attachments into post (2 posts)

  1. vicius
    Member
    Posted 2 years ago #

    Hello,
    For now i'm using such code in single.php to insert images into post:

    <strong>
    Other photos:
    </strong>
    <?php echo do_shortcode('[gallery option1="value1"]'); ?>

    and such code to insert other type attachments:

    <strong>
    Other attachments:
    </strong>
    <ul>
    <?php
    	$args = array(
    		'post_type' => 'attachment',
    		'post_mime_type' => 'application/pdf,application/msword',
    		'numberposts' => -1,
    		'post_status' => null,
    		'post_parent' => $post->ID,
    		'orderby' => 'menu_order',
    		'order' => 'desc'
    		);
    	$attachments = get_posts($args);
    	if ($attachments) {
    		foreach ($attachments as $attachment) {
    		echo '<li><a href="'.wp_get_attachment_url($attachment->ID).'">';
    		echo $attachment->post_title;
    		echo '</a></li>';
    		}
    	}
    ?>
    </ul>

    The problem i have is that even when there is no any images or attachments there is always written such text in the post:
    Other photos:
    Other attachments:

    How to make these texts to appear if only there is uploaded images or other attachment types?

    Thanks in advance..!

  2. vicius
    Member
    Posted 2 years ago #

    Maybe it's too complicated to answer it here in forum and I should think about ordering some professional services to solve that..?

    Thanks in advance..!

Topic Closed

This topic has been closed to new replies.

About this Topic