Post Vorschau zeigt Code von gallery an

  • Hallo zusammen,

    ich erstelle mir gerade ein blog und habe ein Problem mit den Postvorschauen!

    Wenn ich in einem Beitrag eine Gallery einfüge, funktioniert alles bestens (auf der Webseite des Beitrags).

    Sobald ich auf Blog-Übersicht gehe (Vorschau meiner Beiträge), zeigt er mir den Code für die Gallery an.

    Wisst Ihr woran das liegt oder wie ich das anders hinbekomme?

    Über den Weg "more" klappt das natürlich, allerdings gibt es ohnehin schon automatisch ein Permalink zur Seite.

    Über hinweise würde ich mich echt riesig freuen.

    VG

    Einmal editiert, zuletzt von strombose (21. Juni 2013 um 13:33)

    • Anzeige

    Hallo!

    Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.

    • ✔️ Schnelle Ladezeiten (optimiert für WordPress & Co.)
    • ✔️ Deutsche Server & DSGVO-konform
    • ✔️ Persönlicher Support (kein 0815-Ticket-System)

    Mehr erfahren

  • Danke für Deine Antwort!

    Leider bin ich noch nicht ganz so weit, um das ganze zu verstehen.

    Hier mal die
    [h=3]cherry: theme-function.php[/h]


    <?php
    // Set the content width based on the theme's design and stylesheet.
    if ( ! isset( $content_width ) )
    $content_width = 900;

    // The excerpt based on words
    function my_string_limit_words($string, $word_limit){
    $words = explode(' ', $string, ($word_limit + 1));
    if( count($words) > $word_limit )
    array_pop($words);
    return implode(' ', $words).'... ';
    }

    // The excerpt based on character
    function my_string_limit_char($excerpt, $substr=0){
    $string = strip_tags(str_replace('...', '...', $excerpt));
    if ( $substr > 0 ) {
    $string = substr($string, 0, $substr);
    }
    return $string;
    }

    // Remove invalid tags
    function remove_invalid_tags($str, $tags) {
    foreach($tags as $tag) {
    $str = preg_replace('#^<\/'.$tag.'>|<'.$tag.'>$#', '', trim($str));
    }
    return $str;
    }

    // Generates a random string
    function gener_random($length){
    srand((double)microtime()*1000000 );
    $random_id = "";
    $char_list = "abcdefghijklmnopqrstuvwxyz";
    for( $i = 0; $i < $length; $i++ ) {
    $random_id .= substr($char_list,(rand()%(strlen($char_list))), 1);
    }
    return $random_id;
    }

    // Remove Empty Paragraphs
    add_filter('the_content', 'shortcode_empty_paragraph_fix');
    function shortcode_empty_paragraph_fix($content) {
    $array = array (
    '<p>[' => '[',
    ']</p>' => ']',
    ']<br />' => ']'
    );
    $content = strtr($content, $array);
    return $content;
    }

    // Add Thumb Column
    if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) {
    // for post and page
    add_theme_support('post-thumbnails', array( 'post', 'page' ) );
    function fb_AddThumbColumn($cols) {
    $cols['thumbnail'] = theme_locals("thumbnail");
    return $cols;
    }
    function fb_AddThumbValue($column_name, $post_id) {
    $width = (int) 35;
    $height = (int) 35;
    if ( 'thumbnail' == $column_name ) {
    // thumbnail of WP 2.9
    $thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
    // image from gallery
    $attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
    if ($thumbnail_id)
    $thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
    elseif ($attachments) {
    foreach ( $attachments as $attachment_id => $attachment ) {
    $thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
    }
    }
    if ( isset($thumb) && $thumb ) {
    echo $thumb;
    } else {
    echo theme_locals("none");
    }
    }
    }
    // for posts
    add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' );
    add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 );
    // for pages
    add_filter( 'manage_pages_columns', 'fb_AddThumbColumn' );
    add_action( 'manage_pages_custom_column', 'fb_AddThumbValue', 10, 2 );
    }

    // Show filter by categories for custom posts
    function my_restrict_manage_posts() {
    global $typenow;
    $args=array( 'public' => true, '_builtin' => false );
    $post_types = get_post_types($args);
    if ( in_array($typenow, $post_types) ) {
    $filters = get_object_taxonomies($typenow);
    foreach ($filters as $tax_slug) {
    $tax_obj = get_taxonomy($tax_slug);
    wp_dropdown_categories(array(
    'show_option_all' => theme_locals("show_all").$tax_obj->label,
    'taxonomy' => $tax_slug,
    'name' => $tax_obj->name,
    'orderby' => 'term_order',
    // 'selected' => $_GET[$tax_obj->query_var],
    'hierarchical' => $tax_obj->hierarchical,
    'show_count' => false,
    'hide_empty' => true
    ));
    }
    }
    }
    function my_convert_restrict($query) {
    global $pagenow;
    global $typenow;
    if ($pagenow=='edit.php') {
    $filters = get_object_taxonomies($typenow);
    foreach ($filters as $tax_slug) {
    $var = &$query->query_vars[$tax_slug];
    if ( isset($var) ) {
    $term = get_term_by('id',$var,$tax_slug);
    // $var = $term->slug;
    }
    }
    }
    }
    add_action('restrict_manage_posts', 'my_restrict_manage_posts' );
    add_filter('parse_query','my_convert_restrict');

    // Add to admin_init function
    add_action('manage_portfolio_posts_custom_column' , 'custom_portfolio_columns', 10, 2);
    add_filter('manage_edit-portfolio_columns', 'my_portfolio_columns');
    //Add columns for portfolio posts
    function my_portfolio_columns($columns) {
    $columns = array(
    "cb" => "<input type=\"checkbox\" />",
    "title" => theme_locals("title"),
    "portfolio_categories" => theme_locals("categories"),
    "portfolio_tags" => theme_locals("tags"),
    "comments" => "<span><span class=\"vers\"><img src=\"".get_admin_url()."images/comment-grey-bubble.png\" alt=\"Comments\"></span></span>",
    "date" => theme_locals("date"),
    "thumbnail" => theme_locals("thumbnail")
    );
    return $columns;
    }
    function custom_portfolio_columns( $column, $post_id ) {
    switch ( $column ) {
    case 'portfolio_categories':
    $terms = get_the_term_list( $post_id , 'portfolio_category' , '' , ',' , '' );
    if ( is_string( $terms ) ) {
    echo $terms;
    } else {
    echo theme_locals('uncategorized');
    }
    break;
    case 'portfolio_tags':
    $terms = get_the_term_list( $post_id , 'portfolio_tag' , '' , ',' , '' );
    if ( is_string( $terms ) ) {
    echo $terms;
    }
    break;
    }
    }

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!