Advertisement
firoze

Data display in front end wordpress

Oct 28th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.46 KB | None | 0 0
  1.  
  2.  
  3. For Post Type
  4.  
  5. <?php get_post_meta(get_the_ID(),'meta_key_name',true);?>
  6.  
  7. ==============================================================
  8.  
  9.  
  10. For Register Customizer
  11.  
  12. <?php theme_mode('meta_key_name');?>
  13.  
  14. ==============================================================
  15.  
  16. For Settings Items
  17.  
  18. <?php get_option('meta_key_name');?>
  19.  
  20. ==============================================================
  21.  
  22. For Custom Widget
  23.  
  24. <?php get_option('meta_key_name');?>
  25.  
  26. ==============================================================
  27.  
  28. For User Profile Items
  29. <?php echo get_avatar(get_the_author_meta("ID"));?> // avatar picture
  30. <?php echo get_author_posts_url(get_the_author_meta('ID'));?> // user profile url
  31. <?php echo ucfirst(get_the_author());?> // user name
  32. <?php the_author_meta('description');?> // user description
  33.  
  34. <?php get_user_meta(get_the_author_meta('ID'),'meta_key_name',true);?> // from simple meta
  35. <?php get_field('user_social_profile','user_'.get_the_author_meta('ID'));?> // from ACF plugin
  36.  
  37. ==========================================================================================
  38.  
  39. // Attachment image info
  40. <?php
  41.  $id = '_id';
  42.  $meta_img_id = get_post_meta(get_the_ID(),"meta_name$id",true); // get id  
  43.  $alt = get_post_meta($meta_img_id, '_wp_attachment_image_alt', true); // alt text
  44.  $meta_title = get_the_title($meta_img_id);
  45. ?>
  46.  
  47. <?php
  48. $id = '_id';
  49. $meta_img_id = get_post_meta(get_the_ID(),"meta_name$id",true); // get id      
  50. $args = array(
  51.         'post_type' => 'attachment',
  52.         'posts_per_page'=>1,
  53.         'post__in' => array($meta_img_id)
  54.          );
  55.  
  56.     $attachments = get_posts($args);
  57.     echo "<pre>";
  58.     print_r($attachments);
  59.     echo "</pre>";
  60.     ?>
  61.  
  62. <?php
  63. echo $alt = get_post_meta($meta_img_id, '_wp_attachment_image_alt', true);
  64. echo $attachments[0]->post_title;
  65. echo $attachments[0]->post_content;
  66. echo $attachments[0]->post_excerpt;
  67. ?>
  68.  
  69.  
  70. ====================================================================================
  71.  
  72. // Get Theme information
  73. /**
  74. Theme Name: Philosophy
  75. Theme URI: https://rrfiroze.xyz
  76. Author: FIROZE ISLAM
  77. Author URI: https://rrfiroze.xyz
  78. Description: This is our pholosophy system theme.
  79. Version: 0.1
  80. License: GNU General Public License v2 or later
  81. License URI: LICENSE
  82. Text Domain: philosophy
  83. Tags: blog,education "https://make.wordpress.org/themes/handbook/review/required/theme-tags/"
  84. */
  85.  
  86. <?php wp_get_theme()->get('Version');?>
  87. <?php wp_get_theme()->get('License');?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement