Powered By Blogger
Showing posts with label taxonomy. Show all posts
Showing posts with label taxonomy. Show all posts

Wednesday, November 16, 2016

Programmatically Add Post Terms OR custom taxonomy update for post in WordPress

https://tommcfarlin.com/programmatically-add-post-terms/

//custom taxonomy name
$taxonomy = 'location';
$term = term_exists( $user_address, $taxonomy );
// Then we can set the taxonomy
wp_set_post_terms( $postid, $term, $taxonomy, true );

Tuesday, October 11, 2016

pagination in wordpress custom post type category / tags / archive page in wordpress

<?php
/*
Template Name: archive
*/
get_header();
?>

 <!-- <link rel="stylesheet" href="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/css/jPages.css">
  <script type="text/javascript" src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/js/jquery-1.8.2d.min.js"></script>
  <script src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/js/jPages.js"></script>
  <script>
  $(function() {
    $("div.holder").jPages({
      containerID: "itemContainer",
      previous : "←",
      next : "→",
      perPage:5,
      midRange: 5,
      direction: "random"
    });
  });
  </script>-->


<div class="page-heading">
<div class="container">
<div class="col-xs-12">
<h1>Blog</h1>
</div>
</div>
</div>

<div class="container" style="margin-top:30px;">
<div class="col-md-12" id="bread_post"> <?php if(function_exists('bcn_display')){bcn_display();}?>  </div>
<div class="col-md-8 blownew">

 
      <div class="holder"></div>

      <!-- item container -->
    <ul id="itemContainer">

    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <div  id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <!--.post-header-->  
                <div class="entry clear">
<?php
$post_image_id = get_post_thumbnail_id($post_to_use->ID);
if ($post_image_id) {
$thumbnail = wp_get_attachment_image_src( $post_image_id, 'post-thumbnail', false);
if ($thumbnail) (string)$thumbnail = $thumbnail[0];
}
?><li>
<div class="main_blog"><a href="<?php the_permalink(); ?>">
<div style="background:url('<?php echo $thumbnail; ?>') center no-repeat; background-size:100%; height:382px;"></div>
<!-- TITLE -->
<div class="col-md-12 col-sm-12 head_title"><h1><?php the_title(); ?></h1></div>
<div class="col-md-12 col-sm-12 head_title">
<div class="post_view"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/post-view.png"><?php echo do_shortcode('[post-views id=get_the_ID()]'); ?> </div>
<div class="post_date"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/calender.png"><?php the_time( get_option( 'date_format' ) ); ?></div>
<div class="post_author"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/author.png"><?php the_author() ?></div>
<a href="<?php the_permalink(); ?>"><div class="post_comment"><img src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/comments.png"><?php $commentcount = comments_number('0', '1', '%'); $fulltitle = $commentcount . ' comments';
echo $fulltitle; ?></div> </a>
<div class="post_categorynew"><img class="img_cate" src="<?php echo site_url(); ?>/wp-content/themes/elitemcommerce/images/category.png"><?php echo the_category(); ?></div>
</div>
<div class="col-md-12 col-sm-12 new_tag" style="margin-bottom: 16px;"><?php the_tags( '<b>Tags:</b> | ', ' | ', '<br />' ); ?>
</div>
<div class="cont_blog"> <?php $content = get_the_content(); echo mb_strimwidth($content, 0, 350, '...');?>  </div>
<div class="readmore_blog"><a href="<?php the_permalink(); ?>"> Read More </a> </div>
</a>
                    <?php wp_link_pages(); ?>
                </div><!--. entry--> </a>
            </div><!-- .post-->

</a></div>
</li>


        <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>

<!-- Add the pagination functions here. -->
<?php
echo "<div class='blog-nav'>";
// Custom query loop pagination
previous_posts_link( '  <<  ' );

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
 'format' => '?paged=%#%',
 'current' => max( 1, get_query_var('paged') ),
 'total' =>  $wp_query->max_num_pages
) );
next_posts_link( '  >>  ', $custom_query->max_num_pages );
echo "</div>";
                 ?>

</ul>
      <div class="holder"></div>
    <?php  else : ?>
    <?php endif; ?>



</div>
<div class="col-md-4 rightsiderbar_blog"> <?php dynamic_sidebar("right-sidebar"); ?> </div>

</div><!--.content-->
<?php get_footer(); ?>


Friday, May 27, 2016

user details update when user register

function lulzbot_verified_company_user_update(&$edit, $account, $category) {

$domain_name = substr(strrchr($edit[mail], "@"), 1);
$domain = explode('.', $domain_name);


$machine_name = 'companies';
  $v = taxonomy_vocabulary_machine_name_load($machine_name);
  $terms = taxonomy_get_tree($v->vid);
 
  foreach ($terms as $term) {

 if($term->name == $domain[0]){
  $edit[field_user_companies]['und'][0] = $term->tid;
  user_save($account, $edit);
 }
  }

get specific taxonomy below taxonomy in custom module in drupal 7

$machine_name = 'companies';
  $v = taxonomy_vocabulary_machine_name_load($machine_name);
  $terms = taxonomy_get_tree($v->vid);
  foreach ($terms as $term) {
    $options[$term->tid] = $term->name;
  }
  //return $options;
print_r( $options);exit;