• Hi Everyone,

    I got this template that i bought named LMS | Responsive Learning Management System.

    This temaplate comes with a bunch of shortcodes in it. But there is one which is the teachers shortcode, which shows up the teachers of the academy, and it works as follows:

    [dt_sc_teacher columns=”2″ limit=”2″ /]

    Columns limits the number of columns of which the teachers will show up, and limit, limits the amount of theacers to be shown (i think it does this depending on the date of the custom post type). So with the above code it will show 2 teachers in 2 columns.

    The problem is that this is no use for me, as i want to be able to show the teachers by their own POST ID. So i would like to ask you guys if anyone can help me (I got such a limited knowladge of wordpress shortcodes but promisse i will do my best) to add an attribute to this shortcode so it allows me to do something like this:

    [dt_sc_teacher columns=”2″ limit=”2″ ids=”74,80,36,45″ /]

    The file where all the shortcodes are defined for my theme shows the following (i just copied in anything i think is related to the specific shortcode, please let me know if you need the full file):

    /* Teachers Posts */
    
    add_shortcode("dt_sc_teacher", array ( $this, "dt_sc_teacher" ));
    function dt_sc_teacher($attrs, $content = null) {
    
    		extract(shortcode_atts(array(
    
    			'columns' => '',
    
    			'limit' => '',
    
    		), $attrs));
    
    		$columns = !empty($columns) ? $columns : '4';
    
    		$limit = !empty($limit) ? $limit : '-1';
    
    		$col_class = $out = "";
    
    		switch($columns):
    
    			case '1':   $col_class = 'column dt-sc-one-column';   break;
    
    			case '2':   $col_class = 'column dt-sc-one-half';   break;
    
    			case '3':   $col_class = 'column dt-sc-one-third';   break;
    
    			case '4':   $col_class = 'column dt-sc-one-fourth';   break;
    
    			case '5':   $col_class = 'column dt-sc-one-fifth';   break;
    
    			default:    $col_class = 'column dt-sc-one-fourth';   break;
    
    		endswitch;
    
    		$args = array('post_type' => 'dt_teachers', 'posts_per_page' => $limit);
    
    		$wp_query = new WP_Query($args);
    
    		if($wp_query->have_posts()): $i = 1;
    
    		 while($wp_query->have_posts()): $wp_query->the_post();
    
    			$temp_class = ""; global $post;
    
    			if($i == 1) $temp_class = $col_class." first"; else $temp_class = $col_class;
    
    			if($i == $columns) $i = 1; else $i = $i + 1;
    
    			$teacher_settings = get_post_meta ( $post->ID, '_teacher_settings', TRUE );
    
    			$s = "";
    
    			$path = plugin_dir_url ( __FILE__ ) . "images/sociables/";
    
    			if(isset($teacher_settings['teacher-social'])) {
    
    				foreach ( $teacher_settings['teacher-social'] as $sociable => $social_link ) {
    
    					if($social_link != '') {
    
    						$img = $sociable;
    
    						$class = explode(".",$img);
    
    						$class = $class[0];
    
    						$s .= "<li class='{$class}'><a href='{$social_link}'> <img src='{$path}hover/{$img}' alt='{$class}'/>  <img src='{$path}{$img}' alt='{$class}'/> </a>";
    
    					}
    
    				}
    
    			}
    
    			$s = ! empty ( $s ) ? "<div class='dt-sc-social-icons'>
    <ul>$s</ul>
    </div>" : "";
    
    			//FOR AJAX...
    
    			$nonce = wp_create_nonce("dt_team_member_nonce");
    
    			$link = admin_url('admin-ajax.php?ajax=true&action=dttheme_team_member&post_id='.$post->ID.'&nonce='.$nonce);
    
    			$out .= '<div class="'.$temp_class.'">';	
    
    			$out .= "   <div class='dt-sc-team'>";
    
    			$out .= "		<div class='image'>";
    
    								if(get_the_post_thumbnail($post->ID, 'full') != ''):
    
    									$out .= get_the_post_thumbnail($post->ID, 'full');
    
    								else:
    
    									$out .= '<img src="https://placehold.it/400x420" alt="member-image" />';
    
    								endif;
    
    			$out .= " 		</div>";
    
    			$out .= '		<div class="team-details">';
    
    			$out .= '			<h5><a href="'.$link.'">'.get_the_title().'</a></h5>';
    
    								if($teacher_settings['role'] != '')
    
    									$out .= "<h6>".$teacher_settings['role']."</h6>";
    
    								if(isset($teacher_settings['show-social-share']) && $teacher_settings['show-social-share'] != '') $out .= $s;
    
    			$out .= '		</div>';
    
    			$out .= '   </div>';
    
    			$out .= '</div>';	
    
    		 endwhile;
    
    		else: ?>
    
                <h2><?php _e('Nothing Found.', 'dt_themes'); ?></h2>
    
                <p><?php _e('Apologies, but no results were found for the requested archive.', 'dt_themes'); ?></p><?php
    
    		endif;
    
    		return $out;
    
    	}
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter andresmolina

    (@andresmolina)

    Sorry I have translated my post here is I originally wroted it in spanish.

    If someone can help me on above I do appreciate it so much.

    Thanks
    Kind regards

    I got this template that i bought named LMS

    Have you asked the developer of this theme?

    Unlikely anyone here will know how that theme works…

    https://codex.www.ads-software.com/Forum_Welcome#Commercial_Products

    Thread Starter andresmolina

    (@andresmolina)

    Hi,

    No, i havent asked the theme owner mainly because his answers in ThemeForest are always the same.. “Sorry but this functionallity is not available yet”…

    So, i have another idea that could work for my personal situation with this theme. Is it possible to duplicate this custom post type and duplicate the shortcode as well but isntead of name it

    [dt_sc_teacher columns=”2″ limit=”2″ /]

    i could use as well

    [dt_sc_speakers columns=”2″ limit=”2″ /]

    So that way I can show teachers on one side and speakers anywhere else… cause my idea is to put teachers and speakers but do not mix them… and obviously they bot shortcodes should work same way and echo at front office the same way.

    Thanks a lot man

    Thread Starter andresmolina

    (@andresmolina)

    I did post it already on the developers website as a question. But let me ask you one thing… is it really that dificult for someone with good knowledge of PHP and shortcodes at wordpress to help me extending the functionallity of an already existing shortcode? or is it just you as a Moderator showing the forum rules?

    I dont try to be rude with this question, i just want to know if it is a matter of not being able to help me or is a matter of not wanting to help me because of the forum rules…

    Personally, if I knew the answer and it was a fairly simple change, yep, I’d just answer :)!

    EDITED – but alas, I don’t know, sorry.

    Someone else who does may chime in…

    Thread Starter andresmolina

    (@andresmolina)

    Thanks a lot man, apreciate your time and effort.

    I got its solution
    there is a file in the directory .. plugins/designthemes-core-features/shortcodes

    replace line no 1776 with this one
    $args = array(‘post_type’ => ‘dt_teachers’, ‘posts_per_page’ => $limit, ‘order’ => ‘ASC’, ‘orderby’ => ‘name’);

    Hope this will help

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[THEME: LMS] Add attribute to a shortcode’ is closed to new replies.