Plugin Functions

Secondary Title comes with a set of PHP functions that give developers full control over the plugin. To simplify reading, the functions only use the post type post to represent pages and custom post types.

Contents

  1. get_secondary_title
  2. the_secondary_title
  3. has_secondary_title
  4. get_posts_with_secondary_title
  5. get_random_post_with_secondary_title
  6. secondary_title_install
  7. secondary_title_get_default_settings
  8. secondary_title_get_setting
  9. secondary_title_get_settings
  10. secondary_title_reset_settings
  11. more to come...

PHP Functions

get_secondary_title($post_id, $before, $after, $use_settings)

Returns the secondary title of a post to be used with variables and other functions.

Parameters:
  • $post_id (int): The ID of the targeted post. Default: Current post ID.
  • $before (string): A string displayed before the output. Default: Empty.
  • $after (string): A string displays after the output. Default: Empty.
  • $use_settings (bool): Whether or not values of the settings page should be used. Default: false

Returns: string


the_secondary_title($post_id, $before, $after, $use_settings)

Displays the secondary title of a post.

Parameters:
  • $post_id (int): The ID of the targeted post. Default: Current post ID.
  • $before (string): A string displayed before the output. Default: Empty.
  • $after (string): A string displays after the output. Default: Empty.
  • $use_settings (bool): Whether or not values of the settings page should be used. Default: false

Returns: void


has_secondary_title($post_id)

Checks if a post has a secondary title.

Parameters:
  • $post_id (int): The ID of the targeted post. Default: Current post ID.

Returns: true if secondary title exists; false if empty


get_posts_with_secondary_title($additional_query)

Returns an array with posts that have a secondary title.

Parameters:
  • $additional_query (array): Additional query arguments. Optional.

Returns: array


get_random_post_with_secondary_title()

Returns a WP_Post object from one of the posts collected by get_posts_with_secondary_title().


secondary_title_install()

Installs default options.

Return: bool


secondary_title_get_default_settings()

Gets Secondary Title's default settings. The following settings are available:

$default_settings = array(
         "secondary_title_post_types"             => array(),
         "secondary_title_categories"             => array(),
         "secondary_title_post_ids"               => array(),
         "secondary_title_auto_show"              => "on",
         "secondary_title_title_format"           => "%secondary_title%: %title%",
         "secondary_title_input_field_position"   => "above",
         "secondary_title_only_show_in_main_post" => "off",
         "secondary_title_use_in_permalinks"      => "off",
         "secondary_title_permalinks_position"    => "prepend",
         "secondary_title_column_position"        => "right",
         "secondary_title_feed_auto_show"         => "off",
         "secondary_title_feed_title_format"      => "%title%",
         "secondary_title_include_in_search"      => "on",
         "secondary_title_show_donation_notice"   => "on"
      );

Return: array


secondary_title_get_setting($setting)

  • $setting (string): The setting name (without secondary_title\ _prefix).

Returns a specific setting.

Return: mixed


secondary_title_get_settings()

Gives out an array containing the current plugin settings.

Return: array


secondary_title_reset_settings()

Resets all settings to their default state.

Returns: bool

results matching ""

    No results matching ""