cupcakelike
Verfasste Forenbeiträge
-
Forum: Allgemeine Fragen
Als Antwort auf: Passwortschutz bei Beiträgen und Seiten aktivierenHINBEKOMMEN!
Ich habe das ganze mal herausgelöscht und in die single.php eingefügt. also:
<?php /** * The template for displaying all single posts. * * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post * * */ get_header(); ?> <main id="main" class="site-main" role="main"> <?php if ( post_password_required() ) { echo get_the_password_form(); } else { //Photographie if ( array ('cat' => '139',) ) {get_template_part( 'template-parts/content', 'blog_photo');} if ( array ('cat' => '140',) ) {get_template_part( 'template-parts/content', 'blog_events');} //Die hier wurde die ganze zeit korrigiert... }?> </main><!-- #main --> <hr class="mg-tp-80"> <?php get_sidebar(); get_footer();
wenn man als nicht eingeloggter User diese Seite besuchen möchte, kommt die Abfrage *-*
Danke urgernj für den Tipp!!!!
Forum: Allgemeine Fragen
Als Antwort auf: Passwortschutz bei Beiträgen und Seiten aktivieren@urgenj….
Darauf uss man erstmal kommen, dass ACF der Grund sein könnte…
Mein Code sieht nun so aus:<?php /** * Template part for displaying posts. * */ ?> <?php if ( post_password_required() ) { <h1> <?php the_title(); ?></h1> <section> <?php $value = get_field("teaser-text"); if ($value) { ?> <article class="mg-bt-80"> <h3 class="pd-0-15"><?php echo get_field('teaser-text') ?></h3> </article> <?php } if (have_rows('content')): while (have_rows('content')) : the_row(); if (get_row_layout() == 'content_left'): $left_headline = get_sub_field('headline'); $left_text = get_sub_field('text'); $left_image = get_sub_field('image'); $imagetitle = get_sub_field('imagetitle'); ?> <article> <h2><?php echo $left_headline ?></h2> <div class="row"> <div class="col-md-8 col-xs-12"> <?php echo $left_text ?> </div> <div class="col-md-4 col-xs-12"> <a class="swipebox" title="<?php echo $left_image['alt']; ?>" href="<?php echo $left_image['url'] ?>"> <img src="<?php echo $left_image['sizes']['large']; ?>" alt="<?php echo $left_image['alt']; ?>"/> </a> <p class="fs-small text-center pd-tp-10"><?php echo $imagetitle ?></p> </div> </div> </article> <?php endif; ?> <?php if (get_row_layout() == 'content_right'): $right_headline = get_sub_field('headline'); $right_text = get_sub_field('text'); $right_image = get_sub_field('image'); $imagetitle = get_sub_field('imagetitle'); ?> <article> <h2><?php echo $right_headline ?></h2> <div class="row"> <div class="col-md-8 col-xs-12 pull-right"> <?php echo $right_text ?> </div> <div class="col-md-4 col-xs-12 pull-left"> <a class="swipebox" title="" href="<?php echo $right_image['url'] ?>"> <img src="<?php echo $right_image['sizes']['large']; ?>" alt="<?php echo $right_image['alt']; ?>"/> </a> <p class="fs-small text-center pd-tp-10"><?php echo $imagetitle ?></p> </div> </div> </article> <?php endif; endwhile; endif ?> <?php if (have_rows('editing')): while (have_rows('editing')) : the_row(); if (get_row_layout() == 'editing_content'): $editing_before = get_sub_field('before'); $editing_after = get_sub_field('after'); ?> <article> <h2>Vorher/Nachher</h2> <div class="row"> <div class="col-xs-12"> <div id="container-before-after"> <img src="<?php echo $editing_before['sizes']['large']; ?>" alt="<?php echo $editing_before['alt']; ?>"/> <img src="<?php echo $editing_after['sizes']['large']; ?>" alt="<?php echo $editing_after['alt']; ?>"/> </div> </div> </div> </article> <?php endif; endwhile; endif; ?> <?php if (have_rows('image-gallery')): while (have_rows('image-gallery')) : the_row(); if (get_row_layout() == 'gallery'): $gallery_headline = get_sub_field('headline'); $gallery_images = get_sub_field('images'); ?> <article> <h2><?php echo $gallery_headline ?></h2> <?php if ($gallery_images): ?> <div class="row"> <?php foreach ($gallery_images as $image): ?> <section class="col-md-2 col-sm-2 col-xs-4 mg-bt-20"> <a class="swipebox" title="" href="<?php echo $image['url'] ?>"> <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>"/> </a> </section> <?php endforeach; endif; ?> </div> </article> <?php if (have_rows('credits')): ?> <div class="row"> <article class="col-xs-12 mg-tp--40"> <h2>Credits</h2> <div class="pd-0-10"> <?php while (have_rows('credits')) : the_row(); if (get_row_layout() == 'credit_info'): ?> <?php if (have_rows('name')): // loop through the rows of data while (have_rows('name')) : the_row(); // display a sub field value $model_name_titel = get_sub_field('titel'); $name_of_model = get_sub_field('name'); ?> <div class="row"> <div class="col-md-3 col-sm-3 col-xs-12"><b><p><?php echo $model_name_titel; ?></b></div> <div class="col-md-3 col-sm-9 col-xs-12"><p><?php echo $name_of_model; ?></div> </div> <?php endwhile; endif; ?> <?php if (have_rows('social_media')): // loop through the rows of data while (have_rows('social_media')) : the_row(); // display a sub field value $social_media_site = get_sub_field('social-media-site'); $social_media_url = get_sub_field('social-media-url'); ?> <div class="row"> <div class="col-md-3 col-sm-3 col-xs-12"><b><p><?php echo $social_media_site; ?></b></div> <div class="col-md-9 col-sm-9 col-xs-12"><p><?php echo $social_media_url; ?></div> </div> <?php endwhile; endif; ?> <?php endif; endwhile; ?> </div> </div> </article> <?php endif; ?> <?php endif; endwhile; endif; ?> <article> <h2>Infos</h2> <div class="row"> <div class="col-xs-12"> <div class="row"> <div class="col-md-3"><b><p>Datum</b></div> <div class="col-md-9"><p><?php echo the_date(); ?></div> </div> <div class="row"> <div class="col-md-3"><b><p>Kategorie</b></div> <div class="col-md-9"> <p><?php echo get_the_term_list ($post->ID, 'category', '', ', ', '')?></p> </div> </div> <div class="row"> <div class="col-md-3"><b><p>Tags</p></b></div> <div class="col-md-9"><p><?php echo the_tags('', ', ', '');?></p> </div> </div> <div class="row"> <div class="col-md-3"><b><p>Location</p></b></div> <div class="col-md-9"> <p><?php echo get_the_term_list($post->ID, 'location', '', ', ', '') ?></div> </div> </div> </div> </article> </section> <div class="clearfix"></div> <section> <article> <h1>Sharing is Caring!</h1> <div class="row"> <h3 class="text-center mg-bt-40">Hat euch der Beitrag gefallen? Dann teilt ihn doch mit deinen Freunden! <br>Ich freue mich über jeden Support :) - Danke!</h3> <div class="shariff center-block"></div> </div> </article> </section> <section> <?php $post_objects = get_field('choosing_posts'); if( $post_objects ): ?> <h1>Passende Beiträge:</h1> <?php foreach( $post_objects as $post_object): ?> <div class="col-md-6 mg-bt-20"> <a href="<?php echo get_permalink($post_object->ID) ?>"> <?php $headerimage = get_field('header-image', $post_object->ID); ?> <div class="item-background" style="background-image: url(<?php echo $headerimage['url']; ?>)"></div> <div class="transparent-background"> <img class="item-kreis" src="<?php echo get_template_directory_uri() . '/assets/img/kreis.png'; ?>" alt=""> <h3><?php echo get_the_title($post_object->ID)?></h3> </div> </a> </div> <?php endforeach; ?> <?php endif; ?> </section> <div class="clearfix"></div> <section class="mg-tp-40"> <div class="row"> <div class="col-xs-6"> <?php $next_post = get_next_post(); ?> <?php if ( !empty( $next_post ) ) : ?> <a class="" href="<?php echo get_permalink( $next_post->ID ); ?>"><h3>« <?php echo $next_post->post_title; ?></h3></a> <?php endif; ?> </div> <div class="col-xs-6 pull-right text-right"> <?php $prev_post = get_previous_post(); ?> <?php if ( !empty( $prev_post ) ) : ?> <a href="<?php echo get_permalink( $prev_post->ID ); ?>"><h3><?php echo $prev_post->post_title; ?> »</h3></a> <?php endif; ?></div> </div> </section> <div class="clearfix"></div> } ?>
Ergebnis:
Template ohne Inhalt wird angezeigt.
Habe geraude auch das hier Versucht:
if ( post_password_required() ) {echo get_the_password_form();
} else {
[Content]
}Funktioniert ebenfalls nicht…
Auch funktioniert nicht mit einem „!“, also if ( ! post_password_required() )
Forum: Allgemeine Fragen
Als Antwort auf: Passwortschutz bei Beiträgen und Seiten aktivierenErstmal: Vielen Dank für deine Antwort!!! Ist wie so ein Hoffnungsschimmer gerade…
Ich habe mein eigenes Theme erstellt.
Und die template-Datei (falls du die single.php meinst, bzw. jene, die für den content zuständig ist) sieht aktuell so aus:
content-blog_event
<?php /** * Template part for displaying posts. * */ ?> <?php if ( post_password_required() ) { return; } ?> <h1> <?php the_title(); ?></h1> <section> <?php $value = get_field("teaser-text"); if ($value) { ?> <article class="mg-bt-80"> <h3 class="pd-0-15"><?php echo get_field('teaser-text') ?></h3> </article> <?php } if (have_rows('content')): while (have_rows('content')) : the_row(); if (get_row_layout() == 'content_left'): $left_headline = get_sub_field('headline'); $left_text = get_sub_field('text'); $left_image = get_sub_field('image'); $imagetitle = get_sub_field('imagetitle'); ?> <article> <h2><?php echo $left_headline ?></h2> <div class="row"> <div class="col-md-8 col-xs-12"> <?php echo $left_text ?> </div> <div class="col-md-4 col-xs-12"> <a class="swipebox" title="<?php echo $left_image['alt']; ?>" href="<?php echo $left_image['url'] ?>"> <img src="<?php echo $left_image['sizes']['large']; ?>" alt="<?php echo $left_image['alt']; ?>"/> </a> <p class="fs-small text-center pd-tp-10"><?php echo $imagetitle ?></p> </div> </div> </article> <?php endif; ?> <?php if (get_row_layout() == 'content_right'): $right_headline = get_sub_field('headline'); $right_text = get_sub_field('text'); $right_image = get_sub_field('image'); $imagetitle = get_sub_field('imagetitle'); ?> <article> <h2><?php echo $right_headline ?></h2> <div class="row"> <div class="col-md-8 col-xs-12 pull-right"> <?php echo $right_text ?> </div> <div class="col-md-4 col-xs-12 pull-left"> <a class="swipebox" title="" href="<?php echo $right_image['url'] ?>"> <img src="<?php echo $right_image['sizes']['large']; ?>" alt="<?php echo $right_image['alt']; ?>"/> </a> <p class="fs-small text-center pd-tp-10"><?php echo $imagetitle ?></p> </div> </div> </article> <?php endif; endwhile; endif ?> <?php if (have_rows('editing')): while (have_rows('editing')) : the_row(); if (get_row_layout() == 'editing_content'): $editing_before = get_sub_field('before'); $editing_after = get_sub_field('after'); ?> <article> <h2>Vorher/Nachher</h2> <div class="row"> <div class="col-xs-12"> <div id="container-before-after"> <img src="<?php echo $editing_before['sizes']['large']; ?>" alt="<?php echo $editing_before['alt']; ?>"/> <img src="<?php echo $editing_after['sizes']['large']; ?>" alt="<?php echo $editing_after['alt']; ?>"/> </div> </div> </div> </article> <?php endif; endwhile; endif; ?> <?php if (have_rows('image-gallery')): while (have_rows('image-gallery')) : the_row(); if (get_row_layout() == 'gallery'): $gallery_headline = get_sub_field('headline'); $gallery_images = get_sub_field('images'); ?> <article> <h2><?php echo $gallery_headline ?></h2> <?php if ($gallery_images): ?> <div class="row"> <?php foreach ($gallery_images as $image): ?> <section class="col-md-2 col-sm-2 col-xs-4 mg-bt-20"> <a class="swipebox" title="" href="<?php echo $image['url'] ?>"> <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>"/> </a> </section> <?php endforeach; endif; ?> </div> </article> <?php if (have_rows('credits')): ?> <div class="row"> <article class="col-xs-12 mg-tp--40"> <h2>Credits</h2> <div class="pd-0-10"> <?php while (have_rows('credits')) : the_row(); if (get_row_layout() == 'credit_info'): ?> <?php if (have_rows('name')): // loop through the rows of data while (have_rows('name')) : the_row(); // display a sub field value $model_name_titel = get_sub_field('titel'); $name_of_model = get_sub_field('name'); ?> <div class="row"> <div class="col-md-3 col-sm-3 col-xs-12"><b><p><?php echo $model_name_titel; ?></b></div> <div class="col-md-3 col-sm-9 col-xs-12"><p><?php echo $name_of_model; ?></div> </div> <?php endwhile; endif; ?> <?php if (have_rows('social_media')): // loop through the rows of data while (have_rows('social_media')) : the_row(); // display a sub field value $social_media_site = get_sub_field('social-media-site'); $social_media_url = get_sub_field('social-media-url'); ?> <div class="row"> <div class="col-md-3 col-sm-3 col-xs-12"><b><p><?php echo $social_media_site; ?></b></div> <div class="col-md-9 col-sm-9 col-xs-12"><p><?php echo $social_media_url; ?></div> </div> <?php endwhile; endif; ?> <?php endif; endwhile; ?> </div> </div> </article> <?php endif; ?> <?php endif; endwhile; endif; ?> <article> <h2>Infos</h2> <div class="row"> <div class="col-xs-12"> <div class="row"> <div class="col-md-3"><b><p>Datum</b></div> <div class="col-md-9"><p><?php echo the_date(); ?></div> </div> <div class="row"> <div class="col-md-3"><b><p>Kategorie</b></div> <div class="col-md-9"> <p><?php echo get_the_term_list ($post->ID, 'category', '', ', ', '')?></p> </div> </div> <div class="row"> <div class="col-md-3"><b><p>Tags</p></b></div> <div class="col-md-9"><p><?php echo the_tags('', ', ', '');?></p> </div> </div> <div class="row"> <div class="col-md-3"><b><p>Location</p></b></div> <div class="col-md-9"> <p><?php echo get_the_term_list($post->ID, 'location', '', ', ', '') ?></div> </div> </div> </div> </article> </section> <div class="clearfix"></div> <section> <article> <h1>Sharing is Caring!</h1> <div class="row"> <h3 class="text-center mg-bt-40">Hat euch der Beitrag gefallen? Dann teilt ihn doch mit deinen Freunden! <br>Ich freue mich über jeden Support :) - Danke!</h3> <div class="shariff center-block"></div> </div> </article> </section> <section> <?php $post_objects = get_field('choosing_posts'); if( $post_objects ): ?> <h1>Passende Beiträge:</h1> <?php foreach( $post_objects as $post_object): ?> <div class="col-md-6 mg-bt-20"> <a href="<?php echo get_permalink($post_object->ID) ?>"> <?php $headerimage = get_field('header-image', $post_object->ID); ?> <div class="item-background" style="background-image: url(<?php echo $headerimage['url']; ?>)"></div> <div class="transparent-background"> <img class="item-kreis" src="<?php echo get_template_directory_uri() . '/assets/img/kreis.png'; ?>" alt=""> <h3><?php echo get_the_title($post_object->ID)?></h3> </div> </a> </div> <?php endforeach; ?> <?php endif; ?> </section> <div class="clearfix"></div> <section class="mg-tp-40"> <div class="row"> <div class="col-xs-6"> <?php $next_post = get_next_post(); ?> <?php if ( !empty( $next_post ) ) : ?> <a class="" href="<?php echo get_permalink( $next_post->ID ); ?>"><h3>« <?php echo $next_post->post_title; ?></h3></a> <?php endif; ?> </div> <div class="col-xs-6 pull-right text-right"> <?php $prev_post = get_previous_post(); ?> <?php if ( !empty( $prev_post ) ) : ?> <a href="<?php echo get_permalink( $prev_post->ID ); ?>"><h3><?php echo $prev_post->post_title; ?> »</h3></a> <?php endif; ?></div> </div> </section> <div class="clearfix"></div>
Wie gesagt, da habe ich schon irgendwie versucht diese Funktion einzubauen, die aber so nichts bringt… Ich habe sie u.a. bei der comment.php gefunden, da ich diese aber deaktiviert habe, dachte ich zunächst, dass es irgendwie zusammenhängt.