Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Blue Phoenix

    (@blue-phoenix)

    Thanks for the steer, really helped and managed to find a working solution

    <?php
                $display_count = 5;
                $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
                $offset = ($display_count * ($page - 1)) + 1;
    
                $args=array(
                'caller_get_posts'=>1,
                'orderby' => 'title',
                'order'   => 'DESC',
                'posts_per_page' => $display_count,
                'page'       =>  $page,
    	        'offset'     =>  $offset
            );
                $my_query = new WP_Query($args);
                if( $my_query->have_posts() )  {
                while ($my_query->have_posts()) : $my_query->the_post(); ?>
                    <article class="row sub-article">
                        <a href="<?php the_permalink();?>" title="<?php the_title();?>">
                            <div class="col-xs-4">
                                <?php the_post_thumbnail('secondary-thumb', array('class' => 'img-responsive')); ?>
                            </div>
                            <div class="col-xs-8">
                                <h4><?php the_title();?></h4>
                            </div>
                        </a>
                    </article>
    
                <?php endwhile;} ?>
                <?php next_posts_link(); ?>
                <?php previous_posts_link(); ?>
                <?php wp_reset_postdata(); ?>
    Thread Starter Blue Phoenix

    (@blue-phoenix)

    Now I feel a bit of a muppet for something so simple, but that’s resolved the issue.

    Really appreciate your help

    Thread Starter Blue Phoenix

    (@blue-phoenix)

    Functions.php has this

    function my_attachments( $attachments )
    {
    $args = array(
    
    // title of the meta box (string)
    'label' => 'My Attachments',
    
    // all post types to utilize (string|array)
    'post_type' => array( 'post', 'page', 'portfolio' ),
    
    // allowed file type(s) (array) (image|video|text|audio|application)
    'filetype' => image, // no filetype limit
    
    // include a note within the meta box (string)
    'note' => 'Attach files here!',
    
    // text for 'Attach' button in meta box (string)
    'button_text' => __( 'Attach Files', 'attachments' ),
    
    // text for modal 'Attach' button (string)
    'modal_text' => __( 'Attach', 'attachments' ),
    
    /**
    * Fields for the instance are stored in an array. Each field consists of
    * an array with three keys: name, type, label.
    *
    * name - (string) The field name used. No special characters.
    * type - (string) The registered field type.
    * Fields available: text, textarea
    * label - (string) The label displayed for the field.
    */
    
    'fields' => array(
    array(
    'name' => 'title', // unique field name
    'type' => 'text', // registered field type
    'label' => __( 'Title', 'attachments' ), // label to display
    ),
    array(
    'name' => 'caption', // unique field name
    'type' => 'textarea', // registered field type
    'label' => __( 'Caption', 'attachments' ), // label to display
    ),
    array(
    'name' => 'copyright', // unique field name
    'type' => 'text', // registered field type
    'label' => __( 'Copyright', 'attachments' ), // label to display
    ),
    ),
    
    );
    
    $attachments->register( 'my_attachments', $args ); // unique instance name
    }
    
    add_action( 'attachments_register', 'my_attachments' );

    With in the loop of single-portfolio.php the following is added

    <?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>
    <?php if( $attachments->exist() ) : ?>
    
        <?php while( $attachments->get() ) : ?>
    		<img src="<?php echo $attachments->src( 'full' ); ?>"/>
    
        <?php endwhile; ?>
    
    <?php endif; ?>

    Let me know if anything else is required

    [Please post code or markup snippets between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 3 replies - 1 through 3 (of 3 total)