Category : wordpress

Pobieranie wszystkich utworzonych menu function get_all_wordpress_menus(){ return get_terms( 'nav_menu’, array( 'hide_empty’ => true ) ); } sprawdzanie, czy strona ma dzieci function has_children($_id, $_post_type) { $children = get_posts( array( 'post_parent’ => $_id, 'post_type’ => $_post_type ) ); if( count( $children ) == 0 ) { return false; } else { return true; } } szukanie ..

Read more

Czasem wystarczy dodać echo paginate_links( ); W innych przypadkach: $paged = ( get_query_var( 'paged’ ) ) ? absint( get_query_var( 'paged’ ) ) : 1; $projects = new WP_Query(array( 'post_type’ => 'post’, 'posts_per_page’ => 12, 'paged’ => $paged, )); UWAGA: jeżeli query jest na statycznej stronie głównej, to pobieramy zmienną „page” a nie „paged”. następnie do ..

Read more

Całość ładnie opisana tutaj http://vaughnroyko.com/add-custom-class-file-link-in-wordpress/ // Add PDF button next to Add Media function add_pdf_button() { echo '<a href=”#” id=”add-pdf” class=”button” title=”Add PDF”><span class=”dashicons-before dashicons-format-aside wp-media-buttons-icon”></span> Add PDF</a>’; } add_action(’media_buttons’, 'add_pdf_button’, 15); // Include JavaScript for button functionality function include_add_pdf_js_file() { wp_enqueue_script(’media_button’, get_template_directory_uri() . '/js/add-pdf.js’, array(’jquery’), '1.0′, true); } add_action(’wp_enqueue_media’, 'include_add_pdf_js_file’); //Add CSS for editor styling ..

Read more

Htaccess przekierowanie https Podstawowe wp_query $categories = new WP_Query(array( 'post_type’ => 'page’, 'posts_per_page’ => 5, 'meta_key’ => '_wp_page_template’, 'meta_value’ => 'templates/template-category.php’, )); while( $categories->have_posts() ) : $categories->the_post(); endwhile; Pobieranie aktualnego obiektu (wynikającego z zapytania głównego, np kategorii w przypadku strony kategorii $thisCat = $wp_query->get_queried_object(); Pobieranie zmiennej z url-a if( isset( $_GET[’multimedia’] ) ) { $multimedia ..

Read more

Standardowa funkcja w functions.php function custom_fields(){} add_action(’cmb2_init’, 'custom_fields’);   Normalne $field = get_post_meta( get_the_id(), 'field_name’, true ); Meta box zależny od szablonu: $page = new_cmb2_box( array( 'id’ => 'home01′, 'title’ => esc_html__( 'Sekcja 01′, 'cmb2′ ), 'object_types’ => array( 'page’ ), 'show_on’ => array( 'key’ => 'page-template’, 'value’ => 'templates/template-home.php’ ), ) ); Haki WYSIWYG ..

Read more