Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get category
- <h2><?php
- $idObj = get_category_by_slug('s_about'); //ярлык
- $id = $idObj->term_id;
- echo get_cat_name($id);
- ?></h2>
- Get category description
- <?php echo category_description($id); ?>
- Get category title
- <?php the_title(); ?>
- Get category content
- <?php the_content(); ?>
- Get blog name
- <?php echo get_bloginfo('name'); ?>
- Get custom field
- <?php echo get_post_meta($post->ID, 'resume_years', true); ?>
- Post with photo (small\large)
- <div class="row">
- <?php if ( have_posts() ) : query_posts('p=14');
- while (have_posts()) : the_post(); ?>
- <div class="col-md-4 col-md-push-4 animation_1">
- <h3>Фото</h3>
- <div class="person">
- <?php if ( has_post_thumbnail() ) : ?> //img
- <a class="popup" href="<?php
- $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
- echo $large_image_url[0];
- ?>"><?php the_post_thumbnail(array(220, 220)); ?></a>
- <?php endif; ?>
- </div>
- Get post (ul is content)
- <div class="social_wrap">
- <ul>
- <?php
- $idObj = get_category_by_slug('socials');
- $id = $idObj->term_id;?>
- <?php if ( have_posts() ) : query_posts('cat=' . $id);
- while (have_posts()) : the_post(); ?>
- <li><a href="<?php echo get_post_meta($post->ID, 'soc_url', true); ?>" //soc_url is custom field
- target="_blank" title="<?php the_title(); ?>">
- <i class="fa <?php echo get_post_meta($post->ID, 'fonts_awesome', true); ?> ?>"></i></a></li> //fonts_awesome is custom field
- <?php endwhile; endif; wp_reset_query(); ?>
- </ul>
- </div>
- Portfolio
- <div id="portfolio_grid">
- <?php if ( have_posts() ) : query_posts('cat=' . $id);
- while (have_posts()) : the_post(); ?>
- <div class="mix col-md-3 col-sm-6 col-xs-12 portfolio_item
- <?php
- $tags = wp_get_post_tags($post->ID); // get tags
- if ($tags) {
- foreach($tags as $tag) {
- echo ' ' . $tag->name;
- }
- }
- ?> ">
- <?php the_post_thumbnail(array(400, 300)); ?>
- <div class="port_item_cont">
- <h3><?php the_title(); ?></h3>
- <?php the_excerpt(); ?>
- <a href="#" class="popup_content">Посмотреть</a>
- </div>
- <div class="hidden">
- <div class="podrt_descr">
- <div class="modal-box-content">
- <button class="mfp-close" type="button" title="Закрыть (Esc)">×</button>
- <h3><?php the_title(); ?></h3>
- <?php the_content(); ?>
- <img src="<?php
- $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
- echo $large_image_url[0];
- ?>" alt="<?php the_title(); ?>" />
- </div>
- </div>
- </div>
- </div>
- <?php endwhile; endif; wp_reset_query(); ?>
- </div>
- Get option
- <div class="contact_box">
- <div class="contacts_icon icon-basic-geolocalize-05"></div>
- <h3>Адрес:</h3>
- <p><?php $options = get_option('sample_theme_options'); //from theme-options.php
- echo $options['addresstext']; ?></p>
- </div>
- Addres from theme-options.php
- <tr valign="top"><th scope="row"><?php _e( 'Адрес', 'sampletheme' ); ?></th>
- <td>
- <input id="sample_theme_options[addresstext]" class="regular-text" type="text"
- name="sample_theme_options[addresstext]" value="<?php esc_attr_e( $options['addresstext'] ); ?>" />
- </td>
- </tr>
Add Comment
Please, Sign In to add comment