utworzyłem custom post type. Wyświetlam wszystkie wpisy z tej kategorii, Jednak kiedy korzystam z wyszukiwarki nie znajduje ich. Poniżej modyfikacje które zrobiłem dodając i publikując post types. Próbowałem różnych zaawansowanych pluginów. Jednak żaden sobie z tym nie radził. Może Wy coś pomożecie ?
Do category.php dodałem poniższy kod aby wyświetlać wszystkie wpisy.
- Kod: Zaznacz cały
<?php global $post;
$r = new WP_Query(array('posts_per_page' => 0,'post_type' => 'note'));
if ($r->have_posts()) :
echo '<table class="stojan"><tr class="naglowek"><td>Opis</td><td>Numer referencyjny</td></tr>';
while ($r->have_posts()) : $r->the_post();
$custom = get_post_custom($post->ID);
echo '<tr>';
echo '<td>' . $custom["note_content"][0] . '</td>';
echo '<td>' . $custom["ref_post"][0] . '</td>';
echo '</tr>';
endwhile;
echo '</table>';
wp_reset_postdata();
endif;?>
do functions.php dodałem poniższe aby stworzyć custom post types
- Kod: Zaznacz cały
function note_register() {
$args = array(
'label' => __('Stojany'),
'singular_label' => __('Stojan'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title')
);
register_post_type( 'note' , $args );
}
add_action("admin_init", "add_note_info");
function add_note_info() {
add_meta_box("noteInfo-meta", __( 'Stojany informacje') , "meta_options", "note", "normal", "low");
}
function meta_options() {
global $post;
$custom = get_post_custom($post->ID);
$note_content = $custom["note_content"][0];?>
<label style="display: block; margin-bottom: 5px"> <?php _e( 'Nazwa:') ?> </label>
<input type="text" name="note_content" value="<?php echo esc_attr( $note_content ); ?>" size="80" style="width:97%" />
<?php $ref_post = $custom["ref_post"][0]; ?>
<label style="display: block; margin-bottom: 5px"><?php _e( 'Numer referencyjny:') ?></label>
<input type="text" name="ref_post" value="<?php echo esc_attr( $ref_post ); ?>" size="80" style="width:97%" />
<?php }
add_action('save_post', 'save_note_data');
function save_note_data() {
global $post;
update_post_meta($post->ID, "note_content", $_POST["note_content"]);
update_post_meta($post->ID, "ref_post", $_POST["ref_post"]);
}
add_filter("manage_edit-note_columns", "note_edit_columns");
function note_edit_columns($columns) {
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => __('Note title'),
"note_content" => __('Description'),
"ref_post" => __('Reference post'),
'date' => __('Note date'),
);
return $columns;
}
add_action("manage_posts_custom_column", "note_custom_columns");
function note_custom_columns($column) {
global $post;
switch ($column) {
case "note_content":
$custom = get_post_custom();
echo $custom["note_content"][0];
break;
case "ref_post":
$custom = get_post_custom();
echo $custom["ref_post"][0];
break;
}
}