WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Cursorial

Create custom loops and edit it's posts with an easy drag-and-drop interface. Override the post's title, content, excerpt and images. Then d

1. Install the plugin

You can install Cursorial using the built in WordPress plugin installer. If you wish to install Cursorial manually, make sure you've uploaded the plugin to wp-content/plugins/cursorial.

Activate the plugin in the Plugins admin panel using the Activate link. You'll then be able to register your loops and use the widget that follows with this plugin.

2. How to use the widget

Drag the Cursorial Widget to any preferable sidebar in Widget admin panel found in Appearence. You'll then see a list of available loops, called blocks, if you've registered any. If not, you'll be able to create one for the current widget by checking the Custom block radio button. You can set the maximum number of posts and what fields that will be available.

All widget-created blocks are then found in the Custom Widget Blocks admin panel found in the Cursorial menu.

3. Register your loops in the theme's function.php

Use register_cursorial() to register loops. This function takes two arguments. First an array with the loops you want, and then another array with information about how your loops will be shown for the editors in the administration.

Here's some lines of code:

add_action( 'after_setup_theme', 'your_theme_setup' );

function your_theme_setup() {
    if ( function_exists( 'register_cursorial' ) ) {
        register_cursorial(
            array( // Array with the custom loops
                'main-feed' => array( // The key is the name of the loop
                    'label' => __( 'Main Feed' ), // The official label of the loop
                    'max' => 2, // The maximum amount of allowed posts
                    'post_type' => array( 'page' ), // Limit posts with post type. Can be defined as an array or a string
                    'childs' => array( // If set, all posts in this loop can have childs
                        'max' => 2, // The maximum amount of allowed childs posts
                        'post_type' => 'post', // Limit child posts with post type
                        'fields' => array( // Set the displayable child post field
                            'post_title' => array( // The key is the name of the post field
                                'optional' => false, // If set to true, the field can be hidden by the editor in the admin
                                'overridable' => true // If set to true, the field's content can be overridden by the editor in the admin
                            ),
                            'post_date' => array(
                                'optional' => true,
                                'overridable' => false
                            )
                        )
                    ),
                    'fields' => array( // Set the displayable post field
                        'post_title' => array(
                            'optional' => false,
                            'overridable' => true
                        ),
                        'post_excerpt' => array(
                            'optional' => false,
                            'overridable' => true
                        ),
                        'image' => array( // This field will fetch the first occuring image from the post
                            'optional' => true,
                            'overridable' => true
                        )
                    )
                ),
                'second-feed' => array(
                    'label' => __( 'Secondary Feed' ),
                    'max' => 4,
                    'fields' => array(
                        'post_title' => array(
                            'optional' => false,
                            'overridable' => false
                        ),
                        'post_excerpt' => array(
                            'optional' => true,
                            'overridable' => true
                        ),
                        'post_date' => array(
                            'optional' => false,
                            'overridable' => false
                        )
                    )
                )
            ),
            array( // Second argument is an array with some admin config
                __( 'Home' ) => array( // The key is the name of the page where editors can edit specified loops
                    'main-feed' => array( // The key is the name of the loop that will be editable
                        'x' => 0, // In what column this loop should be placed
                        'y' => 0, // In that row this loop should be placed
                        'width' => 2, // How many columns this loop is wide
                        'height' => 7 // How many rows this loop is tall
                    ),
                    'banner-space-1' => array( // If there's no matched loop with this name, the space will be occupied by a dummy placeholder
                        'x' => 2,
                        'y' => 0,
                        'width' => 1,
                        'height' => 2,
                        'dummy-title' => __( 'Banners' ), // A customized title
                        'dummy-description' => __( 'On front page there are a couple of banners here.' ) // A customized description
                    ),
                    'second-feed' => array(
                        'x' => 2,
                        'y' => 2,
                        'width' => 1,
                        'height' => 3
                    )
                ),
                __( 'Sub pages' ) => array( // Another admin page with a set of loops
                    '_dummy' => array(
                        'x' => 0,
                        'y' => 0,
                        'width' => 2,
                        'height' => 7,
                        'dummy-title' => __( 'Page or post content' ),
                        'dummy-description' => __( 'The current page or post content.' )
                    ),
                    'second-feed' => array(
                        'x' => 2,
                        'y' => 0,
                        'width' => 1,
                        'height' => 7
                    )
                )
            )
        );
    }
}

4. Query the posts

There are two ways to print the posts from your customized loops.

You can embed a loop anywhere in your theme with query_cursorial_posts(). This will work almost exactly as if you used query_posts() (see reference). The only difference is that you'll not be able to customize the loop with arguments. query_cursorial_posts() takes only one argument, and that's the name of the loop that you want to get posts from. If you omit this argument, the function will query posts from the first occuring registered loop.

Example:

<?php query_cursorial_posts( 'main-feed' ); ?>
<?php while( have_posts() ): the_post(); ?>
    <div class="post">
        <h2><?php the_title(); ?></h2>
        <?php the_cursorial_image(); ?>
        <?php the_excerpt(); ?>
    </div>
<?php endwhile; ?>

Here with the get_template_part():

<?php query_cursorial_posts( 'main-feed' ); ?>
<?php while( have_posts() ): the_post(); ?>
    <?php get_template_part( 'content', get_post_type() ); ?>
<?php endwhile; ?>

If you want to place all your custom loop code in some other template files you can use get_cursorial_block(). It will call templates called cursorial.php or cursorial-LOOP-NAME.php.

Example:

// In home.php
<?php get_cursorial_block( 'main-feed' ); ?>

// In cursorial-main-feed.php
<?php while( have_posts() ): the_post(); ?>
    <?php get_template_part( 'content', get_post_type() ); ?>
<?php endwhile; ?>

5. Print images, get it's depth and check if a post field is hidden

If you are using the field image (witch is a non wordpress field, added by this plugin), an image is fetched either from a featured image or the first occuring image in the content. It can then be overrided by the editor if you set the field to be overrideable. In order to print this image you need to call the_cursorial_image() or

get_the_cursorial_image()

(witch will return the image tag instead of printing it).

If you've set a loop to support child posts, then you'll need to know what posts are childs or not. With the_cursorial_depth() and

get_the_cursorial_depth()

you'll get an integer for what depth the current post has. 0 for parents and 1 for childs. An important thing to know is that both parents and childs are found in the same loop. There are no nested loops of any kind.

If you've set a field to be optional, an editor may have hidden some posts' fields. You'll notice that the template tag for that field will not return anything. But in some cases you may want to also hide some HTML that wraps the field. With is_cursorial_field_hidden( 'field_name' ) you'll know if the field is set to be hidden.

Example:

<?php while ( have_posts() ) : the_post(); ?>
    <div class="post<?php echo get_the_cursorial_depth() ? ' post-child' : ' post-parent'; ?>
        <h2><a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php esc_attr( get_the_title() ); ?>"><?php the_title(); ?></a></h2>
        <?php if ( ! is_cursorial_field_hidden( 'image' ) ) : ?>
            <div class="image">
                <?php the_cursorial_image(); ?>
            </div>
        <?php endif; ?>
    </div>
<?php endwhile; ?>

Requires: 3.2.1 or higher
Compatible up to: 3.3.2
Last Updated: 2012-2-6
Downloads: 788

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1 100,1,1