Tuesday, August 23, 2016

search 'en' into a string php

<?php  $uri = $_SERVER['REQUEST_URI']; // or taken from another source //
if( strpos($uri, 'en') !== false ){
   // Your action goes here! //
   echo "A place for everything and all in its place";
} else { echo "Un loc pentru toate si toate la locul lor"; }
 ?>

Thursday, August 4, 2016

function create_post_type wp

function create_post_type() {
    register_post_type( 'product',
        array(
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
        'public' => true,
        'has_archive' => true,
        'exclude_from_search' => true,
        'show_ui' => true,
        'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'),
        )
    );
}
add_action( 'init', 'create_post_type' );

function my_taxonomies_product() {
    $labels = array(
        'name'              => _x( 'Product Categories', 'taxonomy general name' ),
        'singular_name'     => _x( 'Product Category', 'taxonomy singular name' ),
        'search_items'      => __( 'Search Product Categories' ),
        'all_items'         => __( 'All Product Categories' ),
        'parent_item'       => __( 'Parent Product Category' ),
        'parent_item_colon' => __( 'Parent Product Category:' ),
        'edit_item'         => __( 'Edit Product Category' ), 
        'update_item'       => __( 'Update Product Category' ),
        'add_new_item'      => __( 'Add New Product Category' ),
        'new_item_name'     => __( 'New Product Category' ),
        'menu_name'         => __( 'Product Categories' ),
    );
    $rewrite = array(
        'slug' => 'type',
        'with_front' => true,
        'hierarchical' => true,
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'rewrite' => $rewrite,
    );
    register_taxonomy( 'product_category', 'product', $args );
}
add_action( 'init', 'my_taxonomies_product', 0 );

Tuesday, August 2, 2016

wp

 function the_titlesmall($before = '', $after = '', $echo = true, $length = false) { $title = get_the_title();

if ( $length && is_numeric($length) ) {
$title = substr( $title, 0, $length );
}

if ( strlen($title)> 0 ) {
$title = apply_filters('the_titlesmall', $before . $title . $after, $before, $after);
if ( $echo )
echo $title;
else
return $title;
}
}



function custom_excerpt_length( $length ) {
        return 20;
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

function cf7_add_post_id(){

    global $post;
    return $post->ID;
}

add_shortcode('CF7_ADD_POST_ID', 'cf7_add_post_id');

echo wp title

<?php
//Set up the variable
$p_title = get_the_title('');
?>


 <?php
                                //echo $p_title;                               
                                 if($p_title == 'Instalatii Civile') {
                                  //$p_title = 'proiecte-instalatii';
                                  echo $p_title;
                                  } else {
                                      $p_title = 'proiecte-constructii' ;
                                     // echo $p_title;
                                  }
 ?>