Largo Project
v0.6.4
  • For Developers
  • Feedback on these docs
  • Support
  • Function reference by file
    • archive.php
    • feed-mailchimp.php
    • functions.php
    • homepages/homepage.php
    • homepages/layouts/HomepageSingleWithSeriesStories.php
    • homepages/zones/zones.php
    • inc/ajax-functions.php
    • inc/avatars.php
    • inc/avatars/functions.php
    • inc/byline_class.php
    • inc/conditionals.php
    • inc/custom-feeds.php
    • inc/custom-less-variables.php
    • inc/customizer/customizer.php
    • inc/dashboard.php
    • inc/deprecated.php
    • inc/editor.php
    • inc/enqueue.php
    • inc/featured-content.php
    • inc/featured-media.php
    • inc/gutenberg-block-edits.php
    • inc/header-footer.php
    • inc/helpers.php
    • inc/images.php
    • inc/metabox-api.php
    • inc/nav-menus.php
    • inc/open-graph.php
    • inc/post-metaboxes.php
    • inc/post-social.php
    • inc/post-tags.php
    • inc/post-templates.php
    • inc/related-content.php
    • inc/sidebars.php
    • inc/taxonomies.php
    • inc/term-icons.php
    • inc/term-meta.php
    • inc/term-sidebars.php
    • inc/update.php
    • inc/users.php
    • inc/verify.php
    • inc/widgets.php
    • inc/widgets/largo-about.php
    • inc/widgets/largo-author-bio.php
    • inc/widgets/largo-facebook.php
    • inc/widgets/largo-image-widget.php
    • inc/widgets/largo-post-series-links.php
    • inc/widgets/largo-recent-comments.php
    • inc/widgets/largo-recent-posts.php
    • inc/widgets/largo-taxonomy-list.php
    • inc/widgets/largo-twitter.php
    • inc/wp-taxonomy-landing/functions/cftl-admin.php
    • inc/wp-taxonomy-landing/functions/cftl-series-order.php
    • options.php
Largo Project
  • Docs »
  • For Developers »
  • Function reference by file »
  • inc/related-content.php
  • Edit on GitHub

inc/related-content.php¶

largo_get_related_topics_for_category()¶

Show related tags and subcategories for each main category Used on category.php to display a list of related terms

Since:0.5.5
Returns:String $TML ‘’ if there are no related topics or a UL if there are related topics
largo_get_post_related_topics()¶

Provides topics (categories and tags) related to the current post in The Loop.

Parameters:
  • $max (int) – The maximum number of topics to return.
Returns:

array $f term objects.

Since:

1.0

largo_get_recent_posts_for_term()¶

Provides the recent posts for a term object (category, post_tag, etc).

Uses:

global $post

Parameters:
  • $term (object) – A term object.
  • $max (int) – Maximum number of posts to return.
  • $min (int) – Minimum number of posts. If not met, returns false.
  • $post__not_in (Array) – Array of integer post IDs to be excluded from the query
Returns:

array|false $f post objects.

Since:

1.0

largo_has_categories_or_tags()¶

Determine if a post has either categories or tags

Returns:bool $rue is a post has categories or tags
Since:1.0
largo_top_term()¶

Returns (and optionally echoes) the ‘top term’ for a post, falling back to a category if one wasn’t specified

Parameters:
  • $options (array|string) – Settings for post id, echo, link, use icon, wrapper and exclude
largo_post_class_top_term()¶

Add the post’s top term to the post’s post_class array

Link:

https://github.com/INN/Largo/issues/1119

Since:

0.5.5

Filter:

post_class

Parameters:
  • $classes (array) – An array of classes on the post
Returns:

array

class Largo_Related¶
The Largo Related class. Used to dig through posts to find IDs related to the current post
__construct()¶

Constructor. Sets up essential parameters for retrieving related posts

Access:

public

Parameters:
  • $number (integer) – optional The number of post IDs to fetch. Defaults to 1
  • $post_id (integer) – optional The ID of the post to get related posts about. If not provided, defaults to global $post
Returns:

null

popularity_sort()¶

Array sorter for organizing terms by # of posts they have

Parameters:
  • $a (object) – First WP term object
  • $b (object) – Second WP term object
Returns:

integer

cleanup_ids()¶

Performs cleanup of IDs list prior to returning it. Also applies a filter.

Access:protected
Returns:array $he final array of related post IDs
get_series_posts()¶

Fetches posts contained within the series(es) this post resides in. Feeds them into $this->post_ids array

Access:protected
See:largo_series_custom_order
get_term_posts()¶

Fetches posts contained within the categories and tags this post has. Feeds them into $this->post_ids array

Access:protected
get_recent_posts()¶

Fetches recent posts. Used as a fallback when other methods have failed to fill post_ids to requested length

Access:protected
ids()¶

Loops through series, terms and recent to fill array of related post IDs. Primary means of using this class.

Access:public
Returns:array $n array of post ids related to the given post
add_from_query()¶

Takes a WP_Query result and adds the IDs to $this->post_ids

Access:

protected

Parameters:
  • $ (object) – WP_Query object
  • $ptional (boolean) – whether the query post order has been reversed yet. If not, this will loop through in both directions.
have_enough_posts()¶

Counts to see if enough posts have been found

Next Previous

© Copyright 2019, Institute for Nonprofit News Revision c41d8519.

Built with Sphinx using a theme provided by Read the Docs.