WordPress.org

Ready to get started?Download WordPress

Forums

Spun
[closed] Problems to capture Title of php (content-home) and change it in CSS (2 posts)

  1. gfr77
    Member
    Posted 1 year ago #

    Hello i've got php code in content-home.php

    <?php
    
    global $post;
    $postclass = '';
    
    if ( '' != get_the_post_thumbnail() ) {
    	$thumb = get_the_post_thumbnail( $post->ID, 'post-thumbnail', array( 'title' => esc_attr( get_the_title() ) ) ) . '<span class="no-thumbnail">' . get_the_title() . '</span>';
    }
    
    else {
    	$args = array(
    				'post_type' => 'attachment',
    				'numberposts' => 1,
    				'post_status' => null,
    				'post_mime_type' => 'image',
    				'post_parent' => $post->ID,
    			);
    
    	$first_attachment = get_children( $args );
    
    	if ( $first_attachment ) {
    		foreach ( $first_attachment as $attachment ) {
    			$thumb = wp_get_attachment_image( $attachment->ID, 'post-thumbnail', false, array( 'title' => esc_attr( get_the_title() ) ) );
    		}
    	}
    	else {
    
    		$postclass = 'no-thumbnail';
    	}
    }
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class( $postclass ); ?>>
    	<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php echo $thumb; ?><?php the_title(); ?></a>
    </article><!-- #post-<?php the_ID(); ?> -->

    But i want to change only the color, alignament, ... of the title but i don't know how.
    In the css (style.css) i try to capture the title to change some parameters i use this in CSS:

    .blog .hentry a, .archive .hentry a, .search .hentry a .attachment-post-thumbnail a{
     position: absolute;
     font-family: Amatic SC;
     font-size: 24px;
     font-style: bold;
     color:#FFFFFF;
     z-index:1;
     top:-50px;
      }

    But this code not change only the title it change the circles and the title, what i'm doing wrong?

    Thanks

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Don't duplicate topics -.-

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.