wordpress shortcode for tab -
I added it to a custom post type but I want to create it with a short statement with a shortcut method. how to do this ? Please answer anyone?
& lt ;? Php $ args = array ('posts_per_page' => 4, 'post_type' = & gt; 'tab-item'); $ Myposts = get_posts ($ Args); ? & Gt; & Lt ;! - nab section date material area - & gt; & Lt; Div class = "date_section_area" & gt; & Lt ;! - Navigation tab - & gt; & Lt; div class = "date_section_list" & gt; & Lt; Ul & gt; & Lt ;? Php foreach ($ myposts $ as post): setup_postdata ($ post); ? & Gt; & Lt; Li & gt; & Lt; a href = "# & lt ;? php the_ID ();? & gt; Data-Toggle = "Tab" & gt; & Lt ;? Php the_title (); ? & Gt; & Lt; / A & gt; & Lt; / li & gt; & Lt ;? php endforeach; wp_reset_postdata (); ? & Gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt ;! - Tab Pains - & gt; & Lt; Div class = "date_section_content" & gt; & Lt ;? php foreach ($ myposts $ as post): setup_postdata ($ post); ? & Gt; & Lt; Div class = "single_date_section_content tab-leaf fade" id = "& lt ;? php the_ID ();? & Gt; & Gt; & Lt ;? Php the_post_thumbnail ('tab-image'); ? & Gt; & Lt ;? php the_content (); ? & Gt; & Lt; / Div & gt; & Lt ;? php endforeach; wp_reset_postdata (); ? & Gt; & Lt; / Div & gt; & Lt; / Div & gt;
As far as I understand your question,
I have an idea you can do this: -
add_shortcode ('my_post_shorcode', 'my_shortcode_function'); Function my_shortcode_function ($ attr, $ content) {remove (shortcode_ts (array '(posts_per_page' = & gt; '4', 'post_type' = & gt; 'tab-item', 'style' = & gt; ), $ Atts)); If ($ style == 'style-1') {// add your style1} and if ($ style == 'style-2') {// add your style} -2 and {$ args = array ( 'Posts_per_page' = & gt; $ posts_per_page, 'post_type' = & gt; $ post_type); $ Myposts = get_posts ($ Args); $ tab_title = ""; $ Tab_content = ""; Foreign currency ($ myposts $ as post) {setup_postdata ($ post); $ tab_title = '& Lt; Li & gt; & Lt; A href = "# tab-post - 'the_ID ().' 'Data-Toggle =" Tab "& gt;' the_title (). ' & lt; / a & gt; & lt; / li & gt; '$ $ tab_content =' & lt; div class = "single_date_section_content tab-pane feed" id = "tab-post - '. the_ID () '& gt; The_post_thumbnail ('tab-image'). The_content () & Lt; / Div & gt; '; Wp_reset_postdata ();}? & Gt; & Lt ;! - nab section date content area - & gt; & Lt; Div class = "date_section_area" & gt; & Lt ;! - Navigation tab - & gt; & Lt; div class = "date_section_list" & gt; & Lt; Ul & gt; & Lt ;? Php echo $ tab_title ;? & Gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt ;! - Tab's Pane - & gt; & Lt; Div class = "date_section_content" & gt; & Lt ;? Php echo $ tab_content ;? & Gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;? php}} and the shortcode will be like this: -
[my_post_shorcode posts_per_page = "4" post_type = "tab-items" style = "default" ] Hope this will help you.
Comments
Post a Comment