WordPress REST API plugin V2
Kategorier
WordPress REST API plugin V2
<?php function my_remove_default_et_pb_custom_search() { remove_action( 'pre_get_posts', 'et_pb_custom_search' ); add_action( 'pre_get_posts', 'my_et_pb_custom_search' ); } add_action( 'wp_loaded', 'my_remove_default_et_pb_custom_search' ); function my_et_pb_custom_search( $query = false ) { if ( is_admin() || ! is_a( $query, 'WP_Query' ) || ! $query->is_search ) { return; } if ( isset( $_GET['et_pb_searchform_submit'] ) ) { $postTypes = array(); if ( ! isset($_GET['et_pb_include_posts'] ) && ! isset( $_GET['et_pb_include_pages'] ) ) $postTypes = array( 'post' ); if ( isset( $_GET['et_pb_include_pages'] ) ) $postTypes = array( 'page' ); if ( isset( $_GET['et_pb_include_posts'] ) ) $postTypes[] = 'post'; /* BEGIN Add custom post types */ $postTypes[] = 'product'; /* END Add custom post types */ $query->set( 'post_type', $postTypes ); if ( ! empty( $_GET['et_pb_search_cat'] ) ) { $categories_array = explode( ',', $_GET['et_pb_search_cat'] ); $query->set( 'category__not_in', $categories_array ); } if ( isset( $_GET['et-posts-count'] ) ) { $query->set( 'posts_per_page', (int) $_GET['et-posts-count'] ); } } }
<span class="pl-k">require_once</span> ( plugin_dir_path(<span class="pl-c1">__FILE__</span>) <span class="pl-k">.</span> <span class="pl-s"><span class="pl-pds">'</span>wp-job-cpt.php<span class="pl-pds">'</span></span> );
Dette viser alle tilgængelige taxonomy terms og ikke kun de valgte. (Alle dem som er i brug på en post). Er der mere end 1, adskilles de med en skråstreg.
<?php $terms = get_terms("custom_taxonomy_navn"); $count = count($terms); $i = 0; if ( $count > 0 ){ foreach ( $terms as $term ) { if ( $i == 0) { echo $term->name; } else { echo " / " . $term->name; } $i++; } } ?>
Guide til at lave post loop på side templates findes på dette link:
http://callmenick.com/post/custom-wordpress-loop-with-pagination
Samme logik kan også bruges på andre elementer
if ( wp_is_mobile() ) { wp_nav_menu( array( 'menu' => 'mobile-menu' ) ); } else { wp_nav_menu( array( 'menu' => 'desktop-menu' ) ); }
Alt indhold til wrappes i en div med dynamisk class.
<div class="<?php echo $c->getPageWrapperClass(); ?>"> </div>
For at registrere et felt i Concrete 5, som kan redigeres i edit-mode bruges følgende.
<?php $a = new Area('job-titel'); $a->display($c); ?>
For at alting virker skal følgende tilføjes lige før det afsluttende head tag.
<?php echo Loader::element("header_required"); ?>
Og følgende lige før det afsluttende body tag.
<?php echo Loader::element("footer_required"); ?>
Bruges til at pege på theme mappen og dermed ramme css, javascript og billedfiler.
<?php echo $view->getThemePath(); ?>