Commit d2d0786d authored by Jakob Moser's avatar Jakob Moser
Browse files

Use WP_Query for landing page to hide what should be hidden

parent 43746e71
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -19,34 +19,38 @@ get_header();
        <?php the_content(); ?>
    </section>
    <section class="news">
        <?php $recent_posts = wp_get_recent_posts(array('numberposts'=>4)); ?>
        <?php 
        // Formulate a query for all posts that are displayed on the "blog" page
        $the_query = new WP_Query("pagename=blog"); 
        ?>

        <?php if ($the_query->have_posts()): ?>
            <?php 
                // Extract the first result from the query. From now on, all the_... methods
                // will use the data from this post
                $the_query->the_post(); 
            ?>

            <article>
                <header>
                <h3><a href="<?php echo get_permalink($recent_posts[0]["ID"]); ?>"><?php echo $recent_posts[0]["post_title"]; ?></a></h3>
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                </header>
                <div class="content">
                <?php
                    if ( !post_password_required($recent_posts[0]["ID"]) ) {
                        echo substr(wp_strip_all_tags($recent_posts[0]["post_content"]), 0, 250).'...';
                    } else {
                        if (get_bloginfo('language') === 'de-DE') {
                            echo "<p>Den Inhalt des Posts k&ouml;nnt ihr euch nach Eingabe des Passworts durchlesen :)</p>";
                        } else {
                            echo "<p>You can only see the content of this post after entering your password. :)</p>";
                        }
                    }
                ?>
                    <?php the_excerpt(); ?>
                </div>
            </article>
        <?php endif; ?>

        <aside>
            <ul>
                <?php for ($i = 1; $i < 4; $i++): ?>
                    <li><a href="<?php echo get_permalink($recent_posts[$i]["ID"])?>" class="headinglike"><?php echo $recent_posts[$i]["post_title"]?></a></li>
                <?php for($i = 0; $i < 3 && $the_query->have_posts(); $i++): ?>
                    <?php $the_query->the_post(); ?>
                    <li><a href="<?php the_permalink(); ?>" class="headinglike"><?php the_title(); ?></a></li>
                <?php endfor; ?>

            </ul>

            <?php wp_reset_postdata(); ?>

            <div class="more">
                <a href="<?php echo home_url()."/blog/"; ?>"><?php
                    if (get_bloginfo('language') === 'de-DE') {
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 * Author: personads :: Maximilian Müller-Eberstein (ursprüngliche Version und Design); Jakob Moser (Code-Rewrite)
 * Author URI: https://personads.me/
 *
 * Version: 1.11
 * Version: 1.12
 *
 * License: GNU General Public License v3.0
 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -16,7 +16,7 @@
 * "Fachschaft Computerlinguistik WordPress Theme" is distributed under the terms of the GNU GPL and can be obtained at
 * https://gitlab.cl.uni-heidelberg.de/fachschaft/fscoli-next/-/tags/original
 *
 * The "fscoli next" WordPress theme contains modifications made by Jakob Moser (2020--2021), which are listed in more detail in
 * The "fscoli next" WordPress theme contains modifications made by Jakob Moser (2020--2022), which are listed in more detail in
 * the README.md provided with this theme. "fscoli next" is distributed under the terms of the GNU GPL.
 *
 * This file contains CSS rules adapted from the Stack Overflow answer https://stackoverflow.com/a/52226523/