Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get taxonomy term id from slug - WordPress

<?php 
    $term = get_term_by('slug', $slug, 'category'); 
    $name = $term->name; 
    $id = $term->term_id;
?>
Comment

taxonomy-{taxonomy-slug}.php

taxonomy-{taxonomy}-{slug}.php
taxonomy-{taxonomy}.php
taxonomy.php
archive.php
index.php
Comment

taxonomy-{taxonomy-slug}.php

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'products',
        array(
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
        'capability_type' => 'post',
        'supports' => array('title','editor','comments'),   
        'public' => true,
        'has_archive' => true,
        'rewrite' => array( 'slug' => 'products' ),
        )
    );
}

function news_init() {
    // create a new taxonomy
    register_taxonomy(
        'products',
        'products',
        array(
            'label' => __( 'Product Categories' ),
            'sort' => true,
            'hierarchical' => true,
            'args' => array( 'orderby' => 'term_order' ),
            'rewrite' => array( 'slug' => 'products-category' )
        )
    );      
}
add_action( 'init', 'news_init' );
Comment

PREVIOUS NEXT
Code Example
Php :: Php OOP function CRUD 
Php :: which is file attributes in php 
Php :: php break and continue 
Php :: strcmp php 
Php :: Publish Spatie Laravel Permission 
Php :: getting routes in middleware laravel 
Php :: laravel sanctum authentication 
Php :: infinite loop php 
Php :: country list laravel 
Php :: socket io laravel 
Php :: laravel enable query log 
Php :: php return multiple variables from function 
Php :: php array 
Php :: php array if 
Php :: php is datetime 
Php :: array to string conversion in laravel controller 
Php :: laravel relationship 
Php :: php string concatenation 
Php :: laravel wherein like 
Php :: extract in php useful 
Php :: in php 
Php :: cache for php website 
Php :: flash message laravel for incorrect password 
Php :: php artisan vendor:publish --provider="SpatieActivitylogActivitylogServiceProvider" --tag="activitylog-migrations" 
Php :: elvis operator php 
Php :: php call static method from class 
Php :: wp functions ajax get 
Php :: check if product has crosssell woocommerce 
Php :: how to put cloth on 3d model using javascript and php 
Php :: enhanced ecommerce data layer for woocommerce 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =