Uncategorized

Get Adjacent Post – V2 series

This function format has been deprecated, see this post instead Previous Post Link for v3 series. – See more at: Get Adjacent Post

Used on single post permalink pages, this return the post type data to the previous/next post.

This tag must be used in The Loop.

The default WordPress function for this is get_adjacent_post however this procedure is very restrictive with the custom order and the terms/taxonomies where to apply.

An improved version is apto_get_adjacent_post function.
Arguments:
apto_get_adjacent_post ($use_custom_order, $term_id, $taxonomy , $previous);

This function should be used along with a custom query

Parameters
$use_custom_order(boolean) Use the custom defined order

$term_id(int) Specify the term id from where the order will apply

$taxonomy(string) Specify the taxonomy name for the $term_id

$previous(boolean) Return Previous or Next

Examples

Return the previous post data using the custom defined order from within the Archive (all posts).
$post_data = apto_get_adjacent_post( TRUE, FALSE, FALSE, TRUE);

Display the previous post data using the default WordPress order:
$post_data = apto_get_adjacent_post( FALSE, FALSE, FALSE, TRUE);

Display the previous post data using the order specified within categories, through term name ‘News Category’ with id 5
$post_data = apto_get_adjacent_post( TRUE, 5, ‘category’, TRUE);

Display the next post data using the order specified within taxonomy ‘Movies’, within term name ‘Titanic’ with id 10
$post_data = apto_get_adjacent_post( TRUE, ’10’, ‘movies’, FALSE);

Next Post Link – V2 Series

This function format has been deprecated, see this post instead Next Post Link for v3 series.

Used on single post permalink pages, this template tag displays a link to the next post which exists in chronological order from the current post.

This tag must be used in The Loop.

The default WordPress function for this is next_post_link. However this is a very limited procedure and there is no way to receive the next post within a taxonomy term and using the custom defined order.

An improvement for that function is next_post_type_link

Arguments:
next_post_type_link($format, $link, $use_custom_order, $term_id, $taxonomy);

Parameters
$format
(string) Format string for the link. This is where to control what comes before and after the link. ‘%link’ in string will be replaced with whatever is declared as ‘link’ (see next parameter). ‘Go to %link’ will generate “Go to <a href=…” Put HTML tags here to style the final results. Defaults to ‘« %link’.

$link
(string) Link text to display. Defaults to next post’s title (‘%title’).

$use_custom_order
(boolean) Use the custom defined order

$term_id
(int) Specify the term id from where the order will apply

$taxonomy
(string) Specify the taxonomy name for the $term_id

Examples

Display the next post link using the custom defined order from within the Archive (all posts).
next_post_type_link( ‘%link’, __( ‘ Next’, ‘twentyeleven’ ), TRUE);

Display the next post link using the default WordPress order:
next_post_type_link( ‘%link’, __( ‘ Next’, ‘twentyeleven’ ), FALSE);

Display the next post link using the order specified within categories, through term name ‘News Category’ with id 5
next_post_type_link( ‘%link’, __( ‘ Next’, ‘twentyeleven’ ), TRUE, ‘5’, ‘category’ );

Display the next post link using the order specified within taxonomy ‘Movies’, within term name ‘Spiderman’ with id 10
next_post_type_link( ‘%link’, __( ‘ Next’, ‘twentyeleven’ ), TRUE, ’10’, ‘movies’ );

Return the next post link using default order from taxonomy ‘Features’ within term ‘App’
next_post_type_link( ‘%link’, __( ‘ Next’, ‘twentyeleven’ ), FALSE, ’15’, features’ );

Previous Post Link – V2 series ( deprecated )

This function format has been deprecated, see this post instead Previous Post Link for v3 series.

Used on single post permalink pages, this template tag displays a link to the previous post which exists in chronological order from the current post.

This tag must be used in The Loop.

The default WordPress function for this is previous_post_link. However this offer a very limited capability and there is no way to receive the previous post within a taxonomy term and using the custom defined order.

An improvement for that function is previous_post_type_link

Arguments:

previous_post_type_link($format, $link, $use_custom_order, $term_id, $taxonomy);

Parameters

$format(string) Format string for the link. This is where to control what comes before and after the link. '%link' in string will be replaced with whatever is declared as 'link' (see next parameter). 'Go to %link' will generate “Go to <a href=…” Put HTML tags here to style the final results. Defaults to '&laquo; %link'.

$link(string) Link text to display. Defaults to previous post’s title ('%title').

$use_custom_order(boolean) Use the custom defined order

$term_id(int) Specify the term id from where the order will apply

$taxonomy(string) Specify the taxonomy name for the $term_id

Examples

Display the previous post link using the custom defined order from within the Archive (all posts).
previous_post_type_link( ‘%link’, __( ‘<span>&larr;</span> Previous’, ‘twentyeleven’ ), TRUE);

Display the previous post link using the default WordPress order:
previous_post_type_link( ‘%link’, __( ‘<span>&larr;</span> Previous’, ‘twentyeleven’ ), FALSE);

Display the previous post link using the order specified within categories, through term name ‘News Category’ with id 5
previous_post_type_link( ‘%link’, __( ‘<span>&larr;</span> Previous’, ‘twentyeleven’ ), TRUE, ‘5’, ‘category’ );

Display the previous post link using the order specified within taxonomy ‘Movies’, within term name ‘Titanic’ with id 10
previous_post_type_link( ‘%link’, __( ‘<span>&larr;</span> Previous’, ‘twentyeleven’ ), TRUE, ’10’, ‘movies’ );

Return the previous post link using default order from taxonomy ‘Features’ within term ‘Design’
previous_post_type_link( ‘%link’, __( ‘<span>&larr;</span> Previous’, ‘twentyeleven’ ), FALSE, ’15’, features’ );

 

Sort WordPress custom post types through Front End – V2 series

This function format is deprecated, see this post instead Sort WordPress custom post types through Front End for v3 series

This is the shortcode format for the old version V2 series.

Sample Usage
[apto_reorder post_type="post"]

Attributes

post_type *required This will hide the Archive sort type from the interface. Only the taxonomies will be show for re-order.
Example
[apto_reorder post_type="post" hide_archive="true"]

hide_archiveThis will hide the Archive sort type from the interface. Only the taxonomies will be show for re-order.
Example
[apto_reorder post_type="post" hide_archive="true"]

taxonomyFilter the post type taxonomies to a single one, using this only the provided taxonomy will be listed. Along with the taxonomy, a drop-down selection will be show to allow the term objects which need sorted.
Example
[apto_reorder post_type="post" taxonomy="category"]

term_slug or term_idFilter a certain term of a given taxonomy, this will become simple interface with drag and drop capability, no additional options are show (i.e. taxonomies selection or archive if set to hide)
Example
[apto_reorder post_type="post" hide_archive="true" taxonomy="category" term_slug="entertainment"]

The interface will look like this:
front-end-sort-of-custom-post-type-single-taxonomy-term

capability The required capability of a user which will be allowed to create the sort. If the user role does not contain that attribute, nothing will be output. For more details about user capabilities and allowed caps see Roles and Capabilities
Example
[apto_reorder post_type="post" capability="edit_pages"]
This shortcode will allow to sort for Editor role and up.

Similar to admin interface, For a given selection, a manual drag and drop capability is available or automatic through which order by ID, name, random, date, custom fields, etc will automatically apply:

front-end-sort-of-custom-post-type-automatic-order

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!