• Resolved juicyjuke

    (@juicyjuke)


    I have my Page-home.php calling a template “content-featured.php”

    Ive tried multiple custom css code snippets for this, and none seem to be working.

    What im trying to do is change JUST the links of Categories this template displays to a specific font.

    how would I go about doing this in this template below?

    below is the code I have in content-featured.php

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    		<?php if( has_post_thumbnail() ): ?>
     
    			<div class="thumbnail"><?php the_post_thumbnail('small'); ?></div>
    
    		<?php endif; ?>
    
    		<?php the_title( sprintf('<h2 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ),'</a></h2>' ); ?>
    
    <?php the_category(); ?>
    
    </article>

    any help id appreciate
    – noob

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter juicyjuke

    (@juicyjuke)

    I want to edit it for just this template only. not globally.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Look at the <body> tag for pages produced by that template and you’ll see that it has a template-specific class added. So you’d do something like

    .template_class h2.entry-title { font-family: somefont; }

    in your CSS.

    Thread Starter juicyjuke

    (@juicyjuke)

    oh im using mini bootstrap for css and JS I entered what you put down in add custom css for that specific page. nothing happened.

    heres the file calling that template

    page-home.php

    <! DOCTYPE html>
    <?php get_header(); ?>
    
    <div class="row">
    
    		<?php 
    
    			$args_cat = array(
    				'include' => '8,10,9,13'
    			);
    
    			$categories = get_categories($args_cat);
    			foreach($categories as $category):
    				
    				$args = array(
    				'type' => 'post',
    				'posts_per_page' => 1,
    				'category__in' => $category->term_id,
    				'category__not_in' => array( 4 ),
    			);
    			
    			$lastBlog = new WP_Query( $args );
    			
    			if( $lastBlog->have_posts() ):
    				
    				while( $lastBlog->have_posts() ): $lastBlog->the_post(); ?>
    
    					<div class="col-xs-12 col-sm-4">
    					
    					<?php get_template_part('content','featured'); ?>
    
    					</div>
    				
    				<?php endwhile;
    				
    			endif;
    			
    			wp_reset_postdata();	
    
    			endforeach;
    
    		
    		?>
    
    </div>
    
    <div class="row">
    	
    	<div class="col-xs-12 col-sm-8">
    
    		<?php 
    		
    		if( have_posts() ):
    			
    			while( have_posts() ): the_post(); ?>
    				
    				<?php get_template_part('content',get_post_format()); ?>
    			
    			<?php endwhile;
    			
    		endif;
    		
    		//PRINT OTHER 2 POSTS NOT THE FIRST ONE
    /*
    		$args = array(
    			'type' => 'post',
    			'posts_per_page' => 2,
    			'offset' => 1,
    		);
    		
    		$lastBlog = new WP_Query($args);
    			
    		if( $lastBlog->have_posts() ):
    			
    			while( $lastBlog->have_posts() ): $lastBlog->the_post(); ?>
    
    				<?php get_template_part('content',get_post_format()); ?>
    			
    			<?php endwhile;
    			
    		endif;
    		
    		wp_reset_postdata();
    */				
    		?>
    		
    		<!-- <hr> -->
    		
    		<?php
    			
    		//PRINT ONLY TUTORIALS
    /*
    		$lastBlog = new WP_Query('type=post&posts_per_page=-1&category_name=midday-atrocity');
    			
    		if( $lastBlog->have_posts() ):
    			
    			while( $lastBlog->have_posts() ): $lastBlog->the_post(); ?>
    				
    				<?php get_template_part('content',get_post_format()); ?>
    			
    			<?php endwhile;
    			
    		endif;
    		
    		wp_reset_postdata();
    */				
    		?>
    	
    	</div>
    	
    	<div class="col-xs-12 col-sm-4">
    		<?php get_sidebar(); ?>
    	</div>
    	
    </div>
    
    <?php get_footer(); ?>
    </html>

    yeah the code doesn’t work in custom css.

    also the only thing I can see for body viewing page source is

    * html body { margin-top: 46px !important; }
    	}
    </style>
    		<style type="text/css" id="wp-custom-css">
    			/*
    You can add your own CSS here.
    
    Click the help icon above to learn more.
    */
    
    		</style>
    	<!-- Dojo Digital Hide Title -->
    <script type="text/javascript">
    	jQuery(document).ready(function($){
    
    		if( $('.entry-title').length != 0 ) {
    			$('.entry-title span.dojodigital_toggle_title').parents('.entry-title:first').hide();
    		} else {
    			$('h1 span.dojodigital_toggle_title').parents('h1:first').hide();
    			$('h2 span.dojodigital_toggle_title').parents('h2:first').hide();
    		}
    
    	});
    </script>
    <noscript><style type="text/css"> .entry-title { display:none !important; }</style></noscript>
    <!-- END Dojo Digital Hide Title -->
    
    			
    	</head>
    		
    	<body class="home page-template-default page page-id-2 logged-in admin-bar no-customize-support custom-background wp-custom-logo crazyjerks-class my_class">
    
    Thread Starter juicyjuke

    (@juicyjuke)

    something is messed up here lmao. I do like the idea of changing fonts for h2 tags tho

    Thread Starter juicyjuke

    (@juicyjuke)

    what about arguments in this function? that possible?

    <?php the_category(); ?>

    Thread Starter juicyjuke

    (@juicyjuke)

    ok I was able to change the fonts for Post entry title in the arguments by simply

    adding

    
    <?php the_title( sprintf('<font face="impact"><h2 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ),'</a></h2></font>' ); ?>
    

    however it didn’t work one bit for cat entry titles haha

    Thread Starter juicyjuke

    (@juicyjuke)

    ok I was able to get it by simply adding the font face html code around the get_category function like

    <font face="impact"><?php the_category(); ?></font>

    is that a good way of doing it steve? anything wrong with that way?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    That’s absolutely the wrong way to do it. Do not set that stuff in PHP. It belongs in CSS. Please re-read my first response and look at the body tag (view page source) on a page produced by that template.

    Thread Starter juicyjuke

    (@juicyjuke)

    <body class="home page-template-default page page-id-2 logged-in admin-bar no-customize-support custom-background wp-custom-logo Juicyjuice-class my_class">
    

    here it is.
    for some reason I cant comprehend what you said.

    how do I apply this to
    this?
    .template_class h2.entry-title { font-family: somefont; }

    I get I can replace somefont to whatever font. ami suppose to replace .template_class with ??

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    The template class for that page is

    .page-template-default, and the specific page class is .page-id-2.

    so

    .page-id-2 h2.entry-title { font-family: somefont; }

    Thread Starter juicyjuke

    (@juicyjuke)

    I should try that before I asked. that was my next step. its the simplest things I find myself having the most trouble with. too focused on complicated things bypassing basics.

    thanks steve. hey not for nothing. you seem to be the only one that responds to my posts around here. People don’t want to deal with noobs or what?

    Thread Starter juicyjuke

    (@juicyjuke)

    one more thing. how can I make that global to effect all pages?

    Thread Starter juicyjuke

    (@juicyjuke)

    oh yeah and that didn’t work. lol just tried it.

    this is what I mean. about ot rip my hair out of my head

    Thread Starter juicyjuke

    (@juicyjuke)

    Trying everything here for what you said. Still isn’t working. Not quite sure how to go about this. Any more info you might need ?

    Thread Starter juicyjuke

    (@juicyjuke)

    My other option here is to just edit h2 tags in custom CSS. I’m guess I’ll just have to stick to that route until I can figure out what the hell is happening . Lol

    But that only works for Posts displayed. Not the title of the category. If I switch the sprintf to the_category instead of the_title that won’t help either

    • This reply was modified 7 years, 11 months ago by juicyjuke.
Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Difficulty editing font type for a specific template’ is closed to new replies.