inc/post-templates.php

is_post_template()

Modelled on is_page_template, determine if we are in a single post template. You can optionally provide a template name and then the check will be specific to that template.

Since:

0.3

Uses:

$wp_query

Parameters:
  • $template (string) – The specific template name if specific matching is required.
Returns:

bool $rue on success, false on failure.

largo_remove_hero()

Remove potentially duplicated hero images in posts

If the first paragraph of the post’s content contains an img tag with a src, and if the src is the same as the src as the post featured media image, or if the src are different but the attachment IDs are the same, then remove the first paragraph from the post’s content to hide the duplicate image.

This does catch img tags inside shortcodes.

This does not remove leading images that are different from the post featured media

permanent in the database. (@see https://github.com/INN/Largo/issues/354)

If you would like to disable this function globally or on certain posts, use the filter largo_remove_hero.

TODO:

The $hanges to the content in this function should eventually be made

Since:

0.4 $ in Largo’s single-column template

Since:

0.5.5 $ in Largo’s two-column template

Parameters:
  • $content (String) – the post content passed in by WordPress filter
Returns:

String $iltered post content.

largo_url_to_attachmentid()

Retrieves the attachment ID from the file URL (or that of any thumbnail image)

Since:0.4
See:https://pippinsplugins.com/retrieve-attachment-id-from-image-url/
Returns:Int $D of post attachment (or false if not found)
largo_get_partial_by_post_type()

Given a post type and an optional context, return the partial that should be loaded for that sort of post.

The default context is search, and the context isn’t actually used by this function, but it is passed to the filter this function runs, largo_partial_by_post_type.

Link:

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

Parameters:
  • $partial (string) – Required, the default partial in this context.
  • $post_type (string) – Required, the given post’s post type
  • $context (string) – Required, the context of this partial.
Returns:

string $he partial that should be loaded. This defaults to ‘search’.

Filter:

largo_partial_by_post_type

Since:

0.5.4