Skip to main content

Posts

Showing posts from October, 2018

How to Fix the HTTP Image Upload Error in WordPress

Increase WordPress Memory Limit 1 define( 'WP_MEMORY_LIMIT' , '256M' ); Change Image Editor Library Used by WordPress 1 2 3 4 5 6 7 function wpb_image_editor_default_to_gd( $editors ) {      $gd_editor = 'WP_Image_Editor_GD' ;      $editors = array_diff ( $editors , array ( $gd_editor ) );      array_unshift ( $editors , $gd_editor );      return $editors ; } add_filter( 'wp_image_editors' , 'wpb_image_editor_default_to_gd' ); Using The .htaccess Method 1 SetEnv MAGICK_THREAD_LIMIT 1

Add pagination on Categories

    <?php     if ( get_query_var( 'paged') )     $paged = get_query_var('paged');     else if ( get_query_var( 'page') )     $paged = get_query_var( 'page');     else     $paged = 1;         $per_page    = 5;     $number_of_series = count( get_terms( 'category') );     $offset  = $per_page * ( $paged - 1);         // Setup the arguments to pass in     $args = array(     'offset'      => $offset,     'number'      => $per_page,     'hide_empty'=>'0'     );         // Gather the series     $series = get_terms( 'category', $args );         // Loop through and display the series     foreach($series as $s)     {     $theurl = get_term_link($s, 'category')...

Get Child Category of a category wordpress

 <?php             $catid = get_queried_object()->term_id;             $args = array('child_of' => $catid);             $categories = get_categories( $args );              if ($categories) {             foreach($categories as $category) {                 echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';                 echo '<p> Description:'. $category->description . '</p>';                 echo '<p> Post Count: '. $category->count . '</p>';              } ...

Add custom Logo in Theme Wordpress

Add this code in function.php file function m1_customize_register( $wp_customize ) {     $wp_customize->add_setting( 'theme_logo' ); // Add setting for logo uploader               // Add control for logo uploader (actual uploader)     $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'theme_logo', array(         'label'    => __( 'School Featured Image', 'm1' ),         'section'  => 'title_tagline',         'settings' => 'theme_logo',     ) ) ); } add_action( 'customize_register', 'm1_customize_register' ); Get logo $theme_logo_url = get_theme_mod( 'theme_logo'); 

get custom post type top level categories

<?php $taxonomy = 'custom_taxonomy_name'; //Choose the taxonomy $terms = get_terms( $taxonomy ); //Get all the terms foreach ($terms as $term) { //Cycle through terms, one at a time // Check and see if the term is a top-level parent. If so, display it. $parent = $term->parent;  if ( $parent=='0' ) { $term_id = $term->term_id; //Define the term ID $term_link = get_term_link( $term, $taxonomy ); //Get the link to the archive page for that term $term_name = $term->name; echo '<a class="ccats" href="' . $term_link . '"><span class="label">' . $term_name . '</span></a>'; } } ?>

Get Woocommerce top level categories

<ul class="topcategories"> <?php $get_featured_cats = array( 'taxonomy'     => 'product_cat', 'orderby'      => 'name', 'hide_empty'   => '0', 'include'      => $cat_array ); $all_categories = get_categories( $get_featured_cats ); $j = 1; foreach ($all_categories as $cat) { $parent = $cat->parent;  if ( $parent=='0' ) { echo "<li>"; $cat_id   = $cat->term_id; $cat_link = get_category_link( $cat_id ); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); // Get Category Thumbnail $image = wp_get_attachment_url( $thumbnail_id ); if ( $image ) { echo '<img src="' . $image . '" alt="" />'; } echo "<br>"; echo $cat->name; // Get Category Name echo "<br>"; echo $cat->description; // Get Category Description $j++; ...