Forum Replies Created

Viewing 15 replies - 16 through 30 (of 44 total)
  • Thread Starter specialmachine

    (@specialmachine)

    Very close! I left it open in case anyone can help me with altering the above to use the category slug instead of the category name.

    Thread Starter specialmachine

    (@specialmachine)

    Aha! So I found this bit of code that does the job of excluding the categories I’m after in the footer.entry-meta element of the Twenty Twelve theme, but it’s using the category names and not the slugs. So at the moment I’m getting the result, particularly in combination with the help I got excluding categories by slug in the sidebar widget, but it’s not quite perfect. Here’s the bit of code I found…

    function the_category_filter($thelist,$separator=' ') {
        if(!defined('WP_ADMIN')) {
            //Category Names to exclude
            $exclude = array('Uncategorized', 'Themes', 'Featured');  
    
            $cats = explode($separator,$thelist);
            $newlist = array();
            foreach($cats as $cat) {
                $catname = trim(strip_tags($cat));
                if(!in_array($catname,$exclude))
                    $newlist[] = $cat;
            }
            return implode($separator,$newlist);
        } else {
            return $thelist;
        }
    }
    add_filter('the_category','the_category_filter', 10, 2);

    And here’s the link to the other bit of exclusion code @alchymyth heroically helped me with for your reference. These two in combination are able to remove the categories I use for traffic duty, categories that populate certain areas of the site by post that I don’t want turning up in the sidebar and in the footer of posts. That’s really powerful stuff for being able to use WordPress as a CMS – at least the way I do it. I’m quite a hack, but if it achieves what the client is after and there’s no great harm, it suits me.

    https://www.ads-software.com/support/topic/excluding-categories-by-slug-from-the-category-widget?replies=4#post-4275214

    Thread Starter specialmachine

    (@specialmachine)

    @alchymyth – I wish I could do something for you. You help me often and always exactly what I need. It’s really something. Thank you, thank you, thank you!

    Thread Starter specialmachine

    (@specialmachine)

    Wonderful. That works extremely well. Can I bother you to ask how I would exclude multiple categories in that snippet?

    Not sure which browser you use, but being able to inspect the element is very helpful to debug things. Here’s a peek at Safari’s version of this browser feature. You can see the CSS definitions in the right column. You would then locate the corresponding styles in your stylesheet and adjust it. You can see these paragraphs have a margin-bottom of 11px.

    https://cl.ly/image/3I0w2w2F471R

    View the source of your page or post or whatever it is an first determine if there are any break tags within your paragraph tags, or if there are any empty paragraph tags. If the code is formed properly, you can simply deal with the margins or padding that is assigned to your paragraph tags and that will help you adjust the spacing between paragraphs.

    Thread Starter specialmachine

    (@specialmachine)

    Thanks for that. Seems a bit over my head at the moment. I could actually just write !is_single and get away with what I’m trying to do, as that does work, but I was baffled as to why is_page() wasn’t working. Thank you and I’ll study what you’ve written a bit more.

    Thread Starter specialmachine

    (@specialmachine)

    For your reference, the whole content.php file within my child theme.

    <?php
    /**
     * The default template for displaying content. Used for both single and index/archive/search.
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    ?>
    
    	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    		<div class="featured-post">
    			<?php _e( 'Featured post', 'twentytwelve' ); ?>
    		</div>
    		<?php endif; ?>	
    
    		<header class="entry-header">
    			<?php if ( is_home() || is_search() ) : // Only display thumbs for index & search ?>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail('featuredImageCropped'); ?></a>
    			<?php endif; ?>
    
    			<?php if ( is_single() ) : ?>
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<?php else : ?>
    
    			<h1 class="entry-title">
    				<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    			</h1>
    
    			<?php endif; // is_single() ?>
    
    			<?php if ( comments_open() ) : ?>
    				<div class="comments-link" style="display:none;"><!-- Edit for comments -->
    					<?php // comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
    				</div><!-- .comments-link -->
    			<?php endif; // comments_open() ?>
    		</header><!-- .entry-header -->
    
    		<?php if ( is_search() || is_home() || is_page() ) : // Only display Excerpts for Search and Index ?>
    		<div class="entry-summary">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-summary -->
    
    		<?php else : ?>
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->
    		<?php endif; ?>
    
    		<footer class="entry-meta">
    			<?php twentytwelve_entry_meta(); ?>
    			<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    			<?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>
    				<div class="author-info">
    					<div class="author-avatar">
    						<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 68 ) ); ?>
    					</div><!-- .author-avatar -->
    					<div class="author-description">
    						<h2><?php printf( __( 'About %s', 'twentytwelve' ), get_the_author() ); ?></h2>
    						<p><?php the_author_meta( 'description' ); ?></p>
    						<div class="author-link">
    							<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
    								<?php printf( __( 'View all posts by %s <span class="meta-nav">&rarr;</span>', 'twentytwelve' ), get_the_author() ); ?>
    							</a>
    						</div><!-- .author-link	-->
    					</div><!-- .author-description -->
    				</div><!-- .author-info -->
    			<?php endif; ?>
    		</footer><!-- .entry-meta -->
    	</article><!-- #post -->

    Excellent. I see no one has answered this and I have the same problem. Uhhhggg.

    Thread Starter specialmachine

    (@specialmachine)

    Yeah, this is for “pages” that have post text or excerpt. And then there are posts that have no images, which is on purpose, like here…

    https://turtleneckclub.com/2013/03/why-do-you-say-life-was-never-meant-to-be-cheap/

    So combining the above that you’ve posted and the earlier example I posted will hopefully be painless. I suppose a bit of hacking never hurt anyone. I’ll have to see what I can do. Thank you so much! And if you have any friends in London, send them right along to our get together on the 18th. ??

    Thread Starter specialmachine

    (@specialmachine)

    Well, the default font size is 16px, as I understand it. So 87.5% of 16 is 14. I don’t know if there’s some smarty pants reason for choosing 14. Why not 10, as has been mentioned? Then it would be 10/16 = 62.5%

    ??

    Thread Starter specialmachine

    (@specialmachine)

    Thank you again!

    Thread Starter specialmachine

    (@specialmachine)

    Here’s that bit in functions.php in twentytwelve…

    function twentytwelve_body_class( $classes ) {
    	$background_color = get_background_color();
    
    	if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) )
    		$classes[] = 'full-width';
    
    	if ( is_page_template( 'page-templates/front-page.php' ) ) {
    		$classes[] = 'template-front-page';
    		if ( has_post_thumbnail() )
    			$classes[] = 'has-post-thumbnail';
    		if ( is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) )
    			$classes[] = 'two-sidebars';
    	}
    
    	if ( empty( $background_color ) )
    		$classes[] = 'custom-background-empty';
    	elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
    		$classes[] = 'custom-background-white';
    
    	// Enable custom font class only if the font CSS is queued to load.
    	if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) )
    		$classes[] = 'custom-font-enabled';
    
    	if ( ! is_multi_author() )
    		$classes[] = 'single-author';
    
    	return $classes;
    }
    add_filter( 'body_class', 'twentytwelve_body_class' );
    Thread Starter specialmachine

    (@specialmachine)

    The only problem is I then lose the body.custom-font-enabled class that’s added when Open Sans is used by default. How I have it that body class is no longer added.

    /* Remove Google Open Sans */
    
    function mytheme_dequeue_fonts() {
    wp_dequeue_style( 'twentytwelve-fonts' );
    }
    
    add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );
    
    /* Enqueue New Google Fonts */
    
    function load_google_fonts() {
    		wp_register_style('googleFontsAbel','https://fonts.googleapis.com/css?family=Abel');
                wp_enqueue_style( 'googleFontsAbel'); 
    
                wp_register_style('googleFontsOldStandardTT','https://fonts.googleapis.com/css?family=Old+Standard+TT');
                wp_enqueue_style( 'googleFontsOldStandardTT');
    
    }
    add_action('wp_print_styles', 'load_google_fonts');
    Thread Starter specialmachine

    (@specialmachine)

    Thank you so much. Worked a treat!

Viewing 15 replies - 16 through 30 (of 44 total)