Guest User

Untitled

a guest
Nov 22nd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. Get category
  2. <h2><?php
  3. $idObj = get_category_by_slug('s_about'); //ярлык
  4. $id = $idObj->term_id;
  5. echo get_cat_name($id);
  6. ?></h2>
  7.  
  8. Get category description
  9. <?php echo category_description($id); ?>
  10.  
  11. Get category title
  12. <?php the_title(); ?>
  13.  
  14. Get category content
  15. <?php the_content(); ?>
  16.  
  17. Get blog name
  18. <?php echo get_bloginfo('name'); ?>
  19.  
  20. Get custom field
  21. <?php echo get_post_meta($post->ID, 'resume_years', true); ?>
  22.  
  23. Post with photo (small\large)
  24. <div class="row">
  25.  
  26. <?php if ( have_posts() ) : query_posts('p=14');
  27. while (have_posts()) : the_post(); ?>
  28. <div class="col-md-4 col-md-push-4 animation_1">
  29. <h3>Фото</h3>
  30. <div class="person">
  31. <?php if ( has_post_thumbnail() ) : ?> //img
  32. <a class="popup" href="<?php
  33. $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
  34. echo $large_image_url[0];
  35. ?>"><?php the_post_thumbnail(array(220, 220)); ?></a>
  36. <?php endif; ?>
  37. </div>
  38.  
  39. Get post (ul is content)
  40. <div class="social_wrap">
  41. <ul>
  42. <?php
  43. $idObj = get_category_by_slug('socials');
  44. $id = $idObj->term_id;?>
  45. <?php if ( have_posts() ) : query_posts('cat=' . $id);
  46. while (have_posts()) : the_post(); ?>
  47.  
  48. <li><a href="<?php echo get_post_meta($post->ID, 'soc_url', true); ?>" //soc_url is custom field
  49. target="_blank" title="<?php the_title(); ?>">
  50. <i class="fa <?php echo get_post_meta($post->ID, 'fonts_awesome', true); ?> ?>"></i></a></li> //fonts_awesome is custom field
  51.  
  52. <?php endwhile; endif; wp_reset_query(); ?>
  53. </ul>
  54. </div>
  55. Portfolio
  56. <div id="portfolio_grid">
  57. <?php if ( have_posts() ) : query_posts('cat=' . $id);
  58. while (have_posts()) : the_post(); ?>
  59.  
  60. <div class="mix col-md-3 col-sm-6 col-xs-12 portfolio_item
  61. <?php
  62. $tags = wp_get_post_tags($post->ID); // get tags
  63. if ($tags) {
  64. foreach($tags as $tag) {
  65. echo ' ' . $tag->name;
  66. }
  67. }
  68. ?> ">
  69. <?php the_post_thumbnail(array(400, 300)); ?>
  70. <div class="port_item_cont">
  71. <h3><?php the_title(); ?></h3>
  72. <?php the_excerpt(); ?>
  73. <a href="#" class="popup_content">Посмотреть</a>
  74. </div>
  75. <div class="hidden">
  76. <div class="podrt_descr">
  77. <div class="modal-box-content">
  78. <button class="mfp-close" type="button" title="Закрыть (Esc)">×</button>
  79. <h3><?php the_title(); ?></h3>
  80. <?php the_content(); ?>
  81. <img src="<?php
  82. $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
  83. echo $large_image_url[0];
  84. ?>" alt="<?php the_title(); ?>" />
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89.  
  90. <?php endwhile; endif; wp_reset_query(); ?>
  91. </div>
  92.  
  93. Get option
  94. <div class="contact_box">
  95. <div class="contacts_icon icon-basic-geolocalize-05"></div>
  96. <h3>Адрес:</h3>
  97. <p><?php $options = get_option('sample_theme_options'); //from theme-options.php
  98. echo $options['addresstext']; ?></p>
  99. </div>
  100.  
  101. Addres from theme-options.php
  102. <tr valign="top"><th scope="row"><?php _e( 'Адрес', 'sampletheme' ); ?></th>
  103. <td>
  104. <input id="sample_theme_options[addresstext]" class="regular-text" type="text"
  105. name="sample_theme_options[addresstext]" value="<?php esc_attr_e( $options['addresstext'] ); ?>" />
  106. </td>
  107. </tr>
Add Comment
Please, Sign In to add comment