Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Konstabel

    (@konstabel)

    I found the problem.

    My search loop was empty. By adding a WP_Query search before I managed to get posts, and then their excerpts.

    The empty query was due to the page address (I am making a custom page).

    <?php $the_query = new WP_Query('define your own query');
        if($the_query->have_posts()):
            while ($the_query->have_posts()): $the_query->the_post();?>
    	    <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
                <p><?php the_excerpt(); ?><p>
    	endwhile;
    
    	else:
    	    echo '<p>Nothing found</p>';
    	endif;
    ?>
    Thread Starter Konstabel

    (@konstabel)

    Perfect thanks.

    Before I was not able to scroll the page if the content was too much.

    For reference, the final code:

    body {
        background-size:cover;
        background-image: url(../images/background.jpg);
    }

    Thread Starter Konstabel

    (@konstabel)

    Thanks GC,

    90% of what I am looking for. I tried it on a test .html document and gives me what I want. But when in WP, nothing happens.

    For the other 10%, how do I run this script on a specific post?

    I added your script to my header.php file, and made the necessary changes to my index.php.

    Below an exerpt of my index.php:

    <nav>
    <ul class="h1list"></ul>
    </nav>
    
    <article class="content"><!-- /content -->
    
    <?php if(have_posts()):
    	while (have_posts()): the_post();?>
    	<article class="post">
    		<h1><a href="<?php the_permalink();?>"><?php the_title();?></a></h1>
    		<?php the_content(); ?>
    		</article>
    	<?php endwhile;
    	else:
    		echo '<p>Geen joernaal inskrywings gevind nie</p>';
    	endif;?><!-- /the-loop -->
    
    </article><!-- /content -->

    Thread Starter Konstabel

    (@konstabel)

    Hey Bob,

    Thanks for your reply. Programming the CSS or finding the file is not my problem.

    I tried amending the body tag through CSS to include a picture, but it did not work.

    This is the code I did try:

    body {
       width: 100%;
       height: 100%;
       background-image: url(../images/background.jpg);
       background-color: #EEE;
    }

    Changing the colour though, does work.

    If I activate add_theme_support( 'custom-background' ); I can add an image through the admin panel, but it does not cover the full screen.

    Thread Starter Konstabel

    (@konstabel)

    Thanks for your help!!

    Thread Starter Konstabel

    (@konstabel)

    I found the problem. 'jQuery' is case sensitive. I used 'jquery'.

    Why is the jQuery option better?

    Thread Starter Konstabel

    (@konstabel)

    Hi Neo,

    Thanks for your reply.

    I got it working by removing the e.preventDefault();.

    I tried implementing your suggestion, but I must be doing something wrong.

    This is what I did:

    <script>
    jquery.noConflict()
    (function($){
      $('#navigation a, #fixedheader a').on('click', function(e) {
      });
    
      $(window).on('scroll',function() {
        var scrolltop = $(this).scrollTop();
    
        if(scrolltop >= 65) {
          $('#fixedheader').fadeIn(500);
        }
    
        else if(scrolltop <= 60) {
          $('#fixedheader').fadeOut(50);
        }
      });
    })(jquery);
    </script>

    What am I not understanding?

    Thread Starter Konstabel

    (@konstabel)

    Finally I got what I wanted:

    <?php
      $args = array( 'numberposts' => '1' );
      $recent_posts = wp_get_recent_posts( $args );
    
      foreach( $recent_posts as $recent ){
      echo '<h3><a href="' . get_permalink($recent["ID"]) . '">' .   $recent["post_title"].'</a></h3>';
      echo $recent["post_content"];
      }
    ?>

    Thread Starter Konstabel

    (@konstabel)

    My very next search got me a solution to post content but not the correct contents.

    I added the line echo $post->post_content;

    The complete code now reads:

    <?php
      $args = array( 'numberposts' => '1' );
      $recent_posts = wp_get_recent_posts( $args );
      foreach( $recent_posts as $recent ){
        echo '<a href="' . get_permalink($recent["ID"]) . '">' .   $recent["post_title"].'</a>';
       echo $post->post_content;
      }
    ?>

    Would still like to hear your comments.

Viewing 9 replies - 1 through 9 (of 9 total)