• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / twentytwenty_get_post_meta() – Retrieves the post meta.

You appear to be a bot. Output may be restricted

Description

Retrieves the post meta.

Usage

twentytwenty_get_post_meta( $post_id, $location );

Parameters

$post_id
( int ) optional – The ID of the post.
$location
( string ) optional default: single-top – The location where the meta is shown.

Returns

void

Source

File name: twentytwenty/inc/template-tags.php
Lines:

1 to 100 of 262
function twentytwenty_get_post_meta( $post_id = null, $location = 'single-top' ) {

  // Require post ID.
  if ( ! $post_id ) {
    return;
  }

  
/**
 * Filters post types array.
 *
 * This filter can be used to hide post meta information of post, page or custom post type
 * registered by child themes or plugins.
 *
 * @since Twenty Twenty 1.0
 *
 * @param array Array of post types
 */
  $disallowed_post_types = apply_filters( 'twentytwenty_disallowed_post_types_for_meta_output', array( 'page' ) );

  // Check whether the post type is allowed to output post meta.
  if ( in_array( get_post_type( $post_id ), $disallowed_post_types, true ) ) {
    return;
  }

  $post_meta_wrapper_classes = '';
  $post_meta_classes         = '';

  // Get the post meta settings for the location specified.
  if ( 'single-top' === $location ) {
    
/**
 * Filters post meta info visibility.
 *
 * Use this filter to hide post meta information like Author, Post date, Comments, Is sticky status.
 *
 * @since Twenty Twenty 1.0
 *
 * @param array $args {
 *  @type string 'author'
 *  @type string 'post-date'
 *  @type string 'comments'
 *  @type string 'sticky'
 * }
 */
    $post_meta = apply_filters(
      'twentytwenty_post_meta_location_single_top',
      array(
        'author',
        'post-date',
        'comments',
        'sticky',
      )
    );

    $post_meta_wrapper_classes = ' post-meta-single post-meta-single-top';

  } elseif ( 'single-bottom' === $location ) {

    
/**
 * Filters post tags visibility.
 *
 * Use this filter to hide post tags.
 *
 * @since Twenty Twenty 1.0
 *
 * @param array $args {
 *   @type string 'tags'
 * }
 */
    $post_meta = apply_filters(
      'twentytwenty_post_meta_location_single_bottom',
      array(
        'tags',
      )
    );

    $post_meta_wrapper_classes = ' post-meta-single post-meta-single-bottom';

  }

  // If the post meta setting has the value 'empty', it's explicitly empty and the default post meta shouldn't be output.
  if ( $post_meta && ! in_array( 'empty', $post_meta, true ) ) {

    // Make sure we don't output an empty container.
    $has_meta = false;

    global $post;
    $the_post = get_post( $post_id );
    setup_postdata( $the_post );

    ob_start();

    ?>

		<div class="post-meta-wrapper<?php echo esc_attr( $post_meta_wrapper_classes ); ?>">

			<ul class="post-meta<?php echo esc_attr( $post_meta_classes ); ?>">

				<?php

        
/**
 
[1] [2] [3] Next »

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: twentytwenty_get_post_meta
Plugin ref: Twenty Twenty
Version: 1.6
Sourcefile: inc/template-tags.php
File ref: inc/template-tags.php
Deprecated?: No
API Letters: G,M,P,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 5.6. PHP: 7.3.26
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites