/home/ivoiecob/ivoiceoutsourcing.net/wp-content/themes/divi-child/functions.php
<?php

function my_theme_enqueue_styles() { 
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );



//add new code here
function register_my_menus() {
  register_nav_menus(
    array(
      'header-top-menu' => __( 'Header Top Menu' ),
		
    )
  );
}
add_action( 'init', 'register_my_menus' );


    include 'custom_post_type_shortcode.php';


/** Services **/
function recent_services_function() {
global $post;

$html = "";

$my_query = new WP_Query( array(
	'post_type' => 'our_services',
	'posts_per_page' => 10,
	'order' => 'ASC'
));

if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post();
		
		$html .= "<div class='services_entry'>";
			$html .= "<div class='services_column_entry'>";
			$html .= "<div class='services_image'>" .get_the_post_thumbnail() . "</div>"; 

			$html .= "<h2>" . get_the_title() . " </h2>";

			$html .= "<div class='services_excerpt'>" .get_the_excerpt() . "</div>"; 

			$html .= "<a href=\"" . get_permalink() . "\" class=\"button\">Learn More</a>";
			$html .= "</div>";
		$html .= "</div>";
	endwhile;
	wp_reset_postdata();
endif;

return $html;
}



/** Team **/
function recent_team_function() {
global $post;

$html = "";

$my_query = new WP_Query( array(
	'post_type' => 'our_team',
	'posts_per_page' => 12,
	'order' => 'ASC'
));

if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post();
		
		$html .= "<div class='team_entry'>";
			$html .= "<div class='team_column_entry'>";
			
			$html .= "<div class='team_image'><a href=\"" . get_permalink() . "\">" .get_the_post_thumbnail() . "</a></div>"; 

			$html .= "<h2><a href=\"" . get_permalink() . "\">" . get_the_title() . " </a></h2>";
			
			$html .= "<p class='team-line'>" . get_field('position') . " </p>";
			

			$html .= "<div class='team_excerpt'>" .get_the_excerpt() . "</div>"; 
			$html .= "</div>";
		$html .= "</div>";
	endwhile;
	wp_reset_postdata();
endif;

return $html;
}

function register_shortcodes(){
	add_shortcode('Services', 'recent_services_function');
	add_shortcode('Team', 'recent_team_function');
}

add_action( 'init', 'register_shortcodes');

add_filter( 'excerpt_length', function($length) {
    return 5;
} );

// trim title
function trim_title(){
	global $post;
	
}add_action('pre_get_posts', 'trim_title');


function trim_the_title( $title )
{
    // limit to 6 words
    if(is_page(1626)){
    	return wp_trim_words( $title, 6, '[...]' );
	}
	return $title;
}
add_filter( 'the_title', 'trim_the_title' );



function print_menu_shortcode($atts, $content = null) {
	
	extract(shortcode_atts(array( 'name' => null, 'class' => null ), $atts));
	return wp_nav_menu( array( 'menu' => $name, 'menu_class' => 'myclass', 'echo' => false ) );
}

add_shortcode('menu', 'print_menu_shortcode');




function add_js_functions(){
?>
<script>
	// Add shortcode to menu
	var sc1 = document.createElement("div");
	var primaryMenu = document.querySelector("#menu-primary-menu-v2");
	
	sc1.innerHTML = "<?php echo do_shortcode("[menu]"); ?>";

	primaryMenu.appendChild(sc1);
	
</script>
<?php
}
add_action('wp_head','add_js_functions');