Forum Replies Created

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter seabear211

    (@seabear211)

    I have tried the following but it shows the image for all:

    if ( has_post_thumbnail() && ! post_password_required() ) {
    
    	$featured_media_inner_classes = '';
    
    	// Make the featured media thinner on archive pages.
    	if ( ! is_singular() ) {
    		$featured_media_inner_classes .= ' medium';
    	}
    	?>
    
    	<figure class="featured-media">
    
    		<div class="featured-media-inner section-inner<?php echo $featured_media_inner_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>">
    
    			<?php
    			the_post_thumbnail();
    
    			$caption = get_the_post_thumbnail_caption();
    
    			if ( $caption ) {
    				?>
    
    				<figcaption class="wp-caption-text"><?php echo wp_kses_post( $caption ); ?></figcaption>
    
    				<?php
    			} 
    	else { 
    			echo 	'<img src="https://st4.depositphotos.com/17828278/24401/v/600/depositphotos_244011872-stock-illustration-image-vector-symbol-missing-available.jpg" alt=""/>';	
    		
    				
    			}
    			?>
    
    		<!-- .featured-media -->
    
    			 
    
    	
    
    	<?php
    } 
    

    I’m currently working on this too. I have got so far, maybe we can work on this together. Here is what I have done.

    I created a child theme (look up how to do this). Then in the child theme, I created the following:

    archive-jetpack-portfolio.php (you can just create archive.php if you are using it for standard blog)

    inside is this code:

    <?php
    /**
     * The main template file
     *
     * This is the most generic template file in a WordPress theme
     * and one of the two required files for a theme (the other being style.css).
     * It is used to display a page when nothing more specific matches a query.
     * E.g., it puts together the home page when no home.php file exists.
     *
     * @link https://developer.www.ads-software.com/themes/basics/template-hierarchy/
     *
     * @package WordPress
     * @subpackage Twenty_Twenty
     * @since Twenty Twenty 1.0
     */
    
    get_header();
    ?>
    
    <main id="site-content" role="main">
    
    	<?php
    
    	$archive_title    = '';
    	$archive_subtitle = '';
    
    	if ( is_search() ) {
    		global $wp_query;
    
    		$archive_title = sprintf(
    			'%1$s %2$s',
    			'<span class="color-accent">' . __( 'Search:', 'twentytwenty' ) . '</span>',
    			'&ldquo;' . get_search_query() . '&rdquo;'
    		);
    
    		if ( $wp_query->found_posts ) {
    			$archive_subtitle = sprintf(
    				/* translators: %s: Number of search results. */
    				_n(
    					'We found %s result for your search.',
    					'We found %s results for your search.',
    					$wp_query->found_posts,
    					'twentytwenty'
    				),
    				number_format_i18n( $wp_query->found_posts )
    			);
    		} else {
    			$archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.', 'twentytwenty' );
    		}
    	} elseif ( is_archive() && ! have_posts() ) {
    		$archive_title = __( 'Nothing Found', 'twentytwenty' );
    	} elseif ( ! is_home() ) {
    		$archive_title    = get_the_archive_title();
    		$archive_subtitle = get_the_archive_description();
    	}
    
    	if ( $archive_title || $archive_subtitle ) {
    		?>
    
    		<header class="archive-header has-text-align-center header-footer-group">
    
    			<div class="archive-header-inner section-inner medium">
    
    				<?php if ( $archive_title ) { ?>
    					<h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1>
    				<?php } ?>
    
    				<?php if ( $archive_subtitle ) { ?>
    					<div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
    				<?php } ?>
    
    			</div><!-- .archive-header-inner -->
    
    		</header><!-- .archive-header -->
    
    		<?php
    	}
    ?>
    <div class="grid" id="container grid">
     <?php
    	if ( have_posts() ) {
    
    		$i = 0;
    
    		while ( have_posts() ) {
    			$i++;
    			if ( $i > 1 ) {
    				echo ' ';
    			}
    			the_post();
    
    			get_template_part( 'template-parts/content-archive-jetpack-portfolio', get_post_type() );
    
    		}
    	} elseif ( is_search() ) {
    		?>
    
    		<div class="no-search-results-form section-inner thin">
    
    			<?php
    			get_search_form(
    				array(
    					'label' => __( 'search again', 'twentytwenty' ),
    				)
    			);
    			?>
    
    		</div></div></div><!-- .no-search-results -->
    
    		<?php
    	}
    	?>
    
    	<?php get_template_part( 'template-parts/pagination' ); ?>
    
    </main><!-- #site-content -->
    
    <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?>
    
    <?php
    get_footer();
    

    You also need this file placed in template parts folder. so it should be located in:
    themename-child -> template-parts -> content-archive-jetpack-portfolio

    <?php 
    	$taxonomy = 'jetpack-portfolio-type'  ; 
        	   $tax_terms = get_the_terms( get_the_ID(), $taxonomy );
        	   ?>
        	   
    
    <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
     
    
    <?php
    /**
     * Displays the post header
     *
     * @package WordPress
     * @subpackage Twenty_Twenty
     * @since Twenty Twenty 1.0
     */
    
    $entry_header_classes = '';
    
    if ( is_singular() ) {
    	$entry_header_classes .= ' header-footer-group';
    }
    
    ?>
    
    <header class="entry-header has-text-align-center<?php echo esc_attr( $entry_header_classes ); ?>">
    
    </header><!-- .entry-header -->
    
     <div class ="box archive-container">
    
    	<div class="entry-header-inner section-inner medium">
    
    		<?php
    		/**
    		 * Allow child themes and plugins to filter the display of the categories in the entry header.
    		 *
    		 * @since Twenty Twenty 1.0
    		 *
    		 * @param bool   Whether to show the categories in header, Default true.
    		 */
    		$show_categories = apply_filters( 'twentytwenty_show_categories_in_entry_header', true );
    
    		if ( true === $show_categories && has_category() ) {
    			?>
    
    			<div class="entry-categories">
    				<span class="screen-reader-text"><?php _e( 'Categories', 'twentytwenty' ); ?></span>
    				<div class="entry-categories-inner">
    					<?php the_category( ' ' ); ?>
    				</div><!-- .entry-categories-inner -->
    			</div><!-- .entry-categories -->
    
    			<?php
    		}
    
    		if ( is_singular() ) {
    			the_title( '<h1 class="entry-title">', '</h1>' );
    		} 
    	else {	
    		?>
    		<div class="portfolio-header">
    			
    		
    		<?php
    		
    			the_title( '<h1 class="entry-title heading-size-1"><a href="' . esc_url( get_permalink() ) . '">', '</a></h2>' );
    		} ?>
    </div>
    		<?php
    		$intro_text_width = '';
    
    		if ( is_singular() ) {
    			$intro_text_width = ' small';
    		} else {
    			$intro_text_width = ' thin';
    		}
    
    		if ( has_excerpt() && is_singular() ) {
    			?>
    
    			<div class="intro-text section-inner max-percentage<?php echo $intro_text_width; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>">
    				<?php the_excerpt(); ?>
    			</div>
    
    	
    		
    			<?php
    		}
    
    		// Default to displaying the post meta.
    		twentytwenty_the_post_meta( get_the_ID(), 'single-top' );
    		?>
    
    	</div><!-- .entry-header-inner -->
    
    	<?php
    
    	if ( ! is_search()  ) {
    		get_template_part( 'template-parts/featured-image' );
    	}
    
    	?>
    
    	<div class="post-inner <?php echo is_page_template( 'templates/template-full-width.php' ) ? '' : 'thin'; ?> ">
      
    		<div class="entry-content">
    	    <div class="portfolio-filter"> 
                 <span class='type'><p><?php the_terms(get_the_ID(), 'jetpack-portfolio-type', ' Type: ',' ? ', ''); ?> </p></span>
                <span class='genre'><p><?php the_terms(get_the_ID(), 'jetpack-portfolio-tag', 'Genres: ',' ? ', ' '); ?> </p></span>
                
                
              <div class="summary"> 
    
    			<?php
    			if ( is_search() || ! is_singular() && 'summary' === get_theme_mod( 'blog_content', 'full' ) ) {
    				the_excerpt();
    			} else {
    				the_content( __( 'Continue reading', 'twentytwenty' ) );
    			}
    			?>
    			</div>  
    </div></div>
    		</div>
    		<!-- .entry-content --><!-- .post-inner -->
    
    	<div class="section-inner">
    
    	    
    		<?php
    		wp_link_pages(
    			array(
    				'before'      => '<nav class="post-nav-links bg-light-background" aria-label="' . esc_attr__( 'Page', 'twentytwenty' ) . '"><span class="label">' . __( 'Pages:', 'twentytwenty' ) . '</span>',
    				'after'       => '</nav>',
    				'link_before' => '<span class="page-number">',
    				'link_after'  => '</span>',
    			)
    		);
    
    		edit_post_link();
    		
    		
    
    		// Single bottom post meta.
    		twentytwenty_the_post_meta( get_the_ID(), 'single-bottom' );
    
    		if ( post_type_supports( get_post_type( get_the_ID() ), 'author' ) && is_single() ) {
    
    			get_template_part( 'template-parts/entry-author-bio' );
    
    		}
    		?>
    
    	</div><!-- .section-inner -->
    
    	<?php
    
    	if ( is_single() ) {
    
    		get_template_part( 'template-parts/navigation' );
    
    	}
    
    	/**
    	 *  Output comments wrapper if it's a post, or if comments are open,
    	 * or if there's a comment number – and check for password.
    	 * */
    	if ( ( is_single() || is_page() ) && ( comments_open() || get_comments_number() ) && ! post_password_required() ) {
    		?>
    
    		<div class="comments-wrapper section-inner">
    
    			<?php comments_template(); ?>
    
    		</div><!-- .comments-wrapper -->
    
    		<?php
    	}
    	?>
    
    </article><!-- .post -->
    

    Then I use this css:

    
    .grid{
      width: 100%;
      height: 100%;
      display: grid;
      grid-template-columns: 1fr 1fr 1fr; 
    	grid-template-rows: 600px;
    	grid-auto-rows: 600px;
    	padding: 20px;
    	grid-column-gap: 15px;
    	grid-row-gap: 15px;
    justify-items: start;
    
    }
    
    .box {
      background-color: beige;
      color: black;
    	background-color: white; 
    	border: solid;
    	height: 600px;
    
    }
    .portfolio-header{
    	height: 4.2em;
    }
    .box h1 a{
    	font-size: 3rem;
    	height: 70px;
    	padding-top: 1rem;
    	padding-bottom: 1rem;
    }

    for two columns you need two “1fr”

    I am trying to get mine so that if one post doesn’t have an image or the text goes onto a second line, it doesn’t matter, everything is perfectly aligned.

    • This reply was modified 3 years, 10 months ago by seabear211.
    Thread Starter seabear211

    (@seabear211)

    ok, I’ve had no joy with this, each time I try and convert the functions it breaks, I don’t know what I’m doing wrong

    Thread Starter seabear211

    (@seabear211)

    Thank you @joyously the 2017 one is much clearer. I’m going to have a look at what the phps are actually doing in that one and see if I can convert it into my theme, thanks

    Thread Starter seabear211

    (@seabear211)

    sorry, I meant this page

    • This reply was modified 4 years, 1 month ago by seabear211.
    Forum: Fixing WordPress
    In reply to: Blog Excerpt
    Thread Starter seabear211

    (@seabear211)

    Thank you, the second link worked

    Thread Starter seabear211

    (@seabear211)

    Thank you, I’ll take a look

    Thread Starter seabear211

    (@seabear211)

    Hi, @kyc4788 I understand about making a page_template-home.php or page_template-onepage.php

    but you lost me at the other part.

    “Then add the function code or create a function in the functions.php to connected to your css/js file so it can appear as static using a post or page.”

    How do I do this ?? thanks for the quick response

    • This reply was modified 4 years, 2 months ago by seabear211.
    • This reply was modified 4 years, 2 months ago by seabear211.
    Thread Starter seabear211

    (@seabear211)

    I solved this: I copied the original archive back into the: taxonomy-jetpack-portfolio-type.php file to make sure it was identical. Then I readded the content-archive-jetpack-portfolio call

    hi can you take your site off coming soon? ??

    Thread Starter seabear211

    (@seabear211)

    Thanks for your help @mikethicke1 Keep safe

    Thread Starter seabear211

    (@seabear211)

    For those who need it, I now have it working:

    
    	<?php
    	$default = infinity_news_get_default_theme_options();
        $ed_social_icon = absint( get_theme_mod( 'ed_social_icon',$default['ed_social_icon'] ) );
        $ed_like_dislike = absint( get_theme_mod( 'ed_like_dislike',$default['ed_like_dislike'] ) );
        $ed_social_share_on_single_page = absint( get_theme_mod( 'ed_social_share_on_single_page',$default['ed_social_share_on_single_page'] ) );
        $infinity_news_archive_layout = esc_html( get_theme_mod( 'infinity_news_archive_layout',$default['infinity_news_archive_layout'] ) );
        $ed_social_share_on_archive_page = esc_html( get_theme_mod( 'ed_social_share_on_archive_page',$default['ed_social_share_on_archive_page'] ) );
        $ed_like_dislike_archive = esc_html( get_theme_mod( 'ed_like_dislike_archive',$default['ed_like_dislike_archive'] ) );
        	$taxonomy = 'jetpack-portfolio-type'  ; 
        	   $tax_terms = get_the_terms( get_the_ID(), $taxonomy );
                 
    
    	if( is_archive() || is_home() || is_front_page() ){
    	?>
    		<div class="post-wrapper">
    	<?php 
    		infinity_news_post_thumbnail();
    	} 
    	?>
    	<div class="portfolio-filter"> 
    	<?php
    
                         $separator = ''; // initialize empty
                    foreach ( $tax_terms as $tax_term ) {
                      echo $separator.'<a class="filter" href="/project-type/'. $tax_term->slug.'">' . $tax_term->name .'</a>';
                      if (empty($separator)) {
                        // Choose a custom separator HERE:
                        $separator = ' | | ';
                      }
                    }

    but the links do not work,I will open a new forum about the links.

    Thread Starter seabear211

    (@seabear211)

    Hi @mikethicke1
    Thank you so much for your help
    I’m getting there now, I have managed to put the terms in the desired place, but if I use:

    $tax_terms = get_the_term_list( get_the_ID(), 'jetpack-portfolio-type' );
    in replace of:
    $tax_terms = get_terms( $taxonomy );
    It comes up blank. I have put the later on the website for now.

    Can you please help me make sure that it says radio for “when the boys come home” and film for “cast”, as in the screenshot I shared before.

    Thanks again

    Thread Starter seabear211

    (@seabear211)

    The theme said something along this: to override create a child theme and create a template part with post-type name

    so I have created content-archive-jetpack-portfolio in my child theme and copied over the existing code.

    Here is the file

    	     <?php
    /**
     * Template part for displaying posts
     *
     * @link https://developer.www.ads-software.com/themes/basics/template-hierarchy/
     *
     * @package Infinity_News
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php if( is_archive() || is_home() || is_front_page() ){ ?> data-aos="fade-up" data-aos-delay="300" <?php } ?>
    >
    
    	<?php
    	$default = infinity_news_get_default_theme_options();
        $ed_social_icon = absint( get_theme_mod( 'ed_social_icon',$default['ed_social_icon'] ) );
        $ed_like_dislike = absint( get_theme_mod( 'ed_like_dislike',$default['ed_like_dislike'] ) );
        $ed_social_share_on_single_page = absint( get_theme_mod( 'ed_social_share_on_single_page',$default['ed_social_share_on_single_page'] ) );
        $infinity_news_archive_layout = esc_html( get_theme_mod( 'infinity_news_archive_layout',$default['infinity_news_archive_layout'] ) );
        $ed_social_share_on_archive_page = esc_html( get_theme_mod( 'ed_social_share_on_archive_page',$default['ed_social_share_on_archive_page'] ) );
        $ed_like_dislike_archive = esc_html( get_theme_mod( 'ed_like_dislike_archive',$default['ed_like_dislike_archive'] ) );
    
    	if( is_archive() || is_home() || is_front_page() ){
    	?>
    		<div class="post-wrapper">
    	<?php 
    		infinity_news_post_thumbnail();
    	} ?>
    		
    		<div class="article-details <?php if( is_single() ){ echo 'single-article-details'; } ?>">
    			
    			<?php if ( 'post' === get_post_type() && is_single() ){ ?>
    				<div class="twp-single-affix">
    
    					<div class="entry-meta">
    			            <?php
    			            infinity_news_posted_by();
    			            echo "<span class='sep-date-author'><i class='ion ion-ios-remove'></i></span>";
    			            infinity_news_posted_on();
    			            ?>
    		            </div>
    
    		            <?php
    		            if( $ed_social_share_on_single_page ){
    			            $args = array('status' => 'enable');
    				        do_action('booster_extension_social_icons',$args);
    				    }
    			        ?>
    
    		        </div><!-- .entry-meta -->
    		    <?php } ?>
    
    		    <div class="twp-post-content">
    
    		    	<?php if ( 'post' === get_post_type() && is_single() ){ infinity_news_post_thumbnail(); } ?>
    
    				<?php if( is_archive() || is_home()|| is_front_page() ) :  ?>
    
    					<header class="entry-header">
    
    						<?php
    
    						if ( 'post' === get_post_type() ){
    		                    echo '<div class="entry-meta entry-meta-category">';
    		                    infinity_news_entry_footer( $cats = true,$tags = false );
    		                    echo '</div>';
    		                }
    
    						the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
    
    						<div class="entry-meta">
    	                        <?php
    	                        infinity_news_posted_by();
    	                        echo "<span class='sep-date-author'><i class='ion ion-ios-remove'></i></span>";
    	                        infinity_news_posted_on();
    	                        ?>
    	                    </div><!-- .entry-meta -->
    
    					</header><!-- .entry-header -->
    
    				<?php endif; ?>
    
    				<div class="entry-content">
    					<?php
    					if( is_single() ):
    
    						the_content();
    
    					else:
    
    						if( has_excerpt() ){
    
    							the_excerpt();
    
    						}else{
    
    							echo esc_html( wp_trim_words( get_the_content(),30,'...') );
    							
    						}
    
    						if( $infinity_news_archive_layout == 'archive-layout-2' && ( is_archive() || ( is_home() && !is_front_page() ) ) ){
                                if( class_exists( 'Booster_Extension_Class') && ( $ed_social_share_on_archive_page || $ed_like_dislike_archive ) ){
                                	
                                    echo "<div class='archive-like-share'>";
                                    if( $ed_social_share_on_archive_page ){
    		                            $args = array('layout'=>'layout-2','status' => 'enable');
                                    	do_action('booster_extension_social_icons',$args);
                                    }
                                    if( $ed_like_dislike_archive ){
    	                                do_action('booster_extension_like_dislike','allenable');
    	                            }
                                    echo "</div>";
                                }
    
    						}else{
    
    							if( class_exists( 'Booster_Extension_Class') && ( is_home() || is_archive() || is_front_page() ) ){
    
    								echo "<div class='archive-like-share'>";
    
    								if( is_archive() || ( is_home() && !is_front_page() ) ){
    									if( $ed_social_share_on_archive_page ){
    									$args = array('layout'=>'layout-2','status' => 'enable');
    										do_action('booster_extension_social_icons',$args);
    									}
    								}else{
    									if( $ed_social_icon ){
    										$args = array('layout'=>'layout-2','status' => 'enable');
    										do_action('booster_extension_social_icons',$args);
    									}
    								}
    						        
    						        
    
    						        if( is_front_page() && is_home() ){
    
    							        $default = infinity_news_get_default_theme_options();
    							        $twp_infinity_news_home_sections = get_theme_mod( 'twp_infinity_news_home_sections', json_encode( $default['twp_infinity_news_home_sections'] ) );
    							        $twp_infinity_news_home_sections = json_decode( $twp_infinity_news_home_sections );
    
    							        foreach( $twp_infinity_news_home_sections as $infinity_news_home_section ){
    
    							            $home_section_type = isset( $infinity_news_home_section->home_section_type ) ? $infinity_news_home_section->home_section_type : '' ;
                							switch( $home_section_type ){
    
    							                case 'latest-post':
    							                $latest_post_layout = isset( $infinity_news_home_section->latest_post_layout ) ? $infinity_news_home_section->latest_post_layout : '' ;
    
    									        if( class_exists( 'Booster_Extension_Class') && $ed_like_dislike && $latest_post_layout == 'index-layout-2' ){
    							                    do_action('booster_extension_like_dislike','allenable');
    							                }
    
    							                break;
    
    							            }
    
    							        }
    							    }
    
    						        echo "</div>";
    							}
    						}
    
    					endif;
    
    					wp_link_pages( array(
    						'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'infinity-news' ),
    						'after'  => '</div>',
    					) );
    					?>
    				</div><!-- .entry-content -->
    
    				<?php
    					if( is_single() ){
    						$tags = true;
    					}else{
    						$tags = false;
    					}
    				?>
    				<footer class="entry-footer">
    					<?php infinity_news_entry_footer( $cats = false,$tags ); ?>
    				</footer><!-- .entry-footer -->
    			</div>
    
    		</div>
    
    	<?php if( is_archive() || is_home() || is_front_page() ){ ?>
    		</div>
    	<?php } ?>
    
    </article><!-- #post-<?php the_ID(); ?> -->
    
    • This reply was modified 4 years, 6 months ago by seabear211.
    Thread Starter seabear211

    (@seabear211)

    Hi thanks

    once I create a child theme, what would I need to do? I am new to PHP ??

Viewing 15 replies - 1 through 15 (of 18 total)