Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter fikolab

    (@fikolab)

    I’m close, at the moment the code of content-sticky.php is this:

    <?php
    /**
     * The default template for displaying content
     *
     * Used for both single and index/archive/search.
     *
     * @package Resonar
     * @since Resonar 1.0
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<?php if ( has_post_thumbnail() && ! post_password_required() ) :
      $featuredimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'resonar-large' );
      ?>
    		<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
    			<?php the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) ); ?>
    		</a>
    
      <div class="entry-header-background" style="background-image:url(<?php echo esc_url( $featuredimage[0] ); ?>)">
    			<div class="entry-header-wrapper">
    				<header class="entry-header">
    					<div class="entry-header-inner">
    						<div class="entry-date">
    							<?php resonar_entry_date(); ?>
    						</div>
    
    						<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
    					</div>
    				</header>
    			</div>
    		</div>
    	<?php endif; ?>
    
    	<?php if ( 'post' == get_post_type() ) : ?>
    		<div class="entry-date">
    			<?php resonar_entry_date(); ?>
    		</div><!-- .entry-date -->
    	<?php endif; ?>
    
    	<?php the_title( sprintf( '<header class="entry-header"><h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2></header>' ); ?>
    
    	<div class="entry-summary">
    	    <?php
    	        if ( strpos( $post->post_content, '<!--more' ) ) {
    	            the_content( sprintf(
    	                /* translators: %s: Name of current post. */
    	                wp_kses( __( 'Continue reading %s', 'resonar' ), array( 'span' => array( 'class' => array() ) ) ),
    	                the_title( '<span class="screen-reader-text">"', '"</span>', false )
    	            ) );
    	        } else {
    	            the_excerpt();
    	        }
    	    ?>
    	</div><!-- .entry-summary -->
    </article><!-- #post-## -->
    

    the featured image is separate from the title, I need it as background of the title. Also show the preview of the post, but I don’t need it.

    Some idea about the code?

    Thread Starter fikolab

    (@fikolab)

    I added the file “content-sticky.php” in my child theme folder with this code:

    <?php if (is_home()) {
                $sticky = get_option( 'sticky_posts' ); // Get all sticky posts
    
                $args = array(
                      'posts_per_page' => 1,
                      'post__in'  => $sticky,
                      'ignore_sticky_posts' => 1
                );
                $query = new WP_Query( 'p=' . $sticky[0] );
    
                if( $query->have_posts() ) {
                      while( $query->have_posts() ) {
                            $query->the_post();
                      ?>
                            <div class="trend-post">
                            <div class="thumb"><?php the_post_thumbnail(); ?></div>
                            <div class="title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></div></div>
                      <?php
                      }
                      wp_reset_query();
                }
            }
    ?>

    Now the sticky post is shown, but it’s just a little image in the corner of the page. Which part of the code I need change to see the sticky post in this way: https://resonardemo.wordpress.com/ ?

    Thread Starter fikolab

    (@fikolab)

    Hey Fotis,
    thanks for your solution. I replaced the featured image with a bigger one (2560 per 1707 pixel), but nothing, same problem.

    I think that I need change something in the header code :/
    some idea?

    Thread Starter fikolab

    (@fikolab)

    Many thanks to you for the answer,

    Yes it is. The homepage is set to show the latest posts.

    i.e. the post fiko:Brew it was the last post shown, but when I marked it as “sticky post” it disappeared from the home page.

    Thread Starter fikolab

    (@fikolab)

    Hi Adam,
    the post that I setted as sticky is “fiko:Brew”.

    you can see a screenshot from my wp dashboard/post list here: https://drive.google.com/file/d/1lqgbj2KczW9W3U_IIAdaVS9ooTCr8A3d/view?usp=sharing

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