Support » Themes and Templates » Dynamic post titles on the frontpage

  • Resolved erikhgm


    Is there a way to have the post titles on the main page to automatically change between a random set of sizes and font types For example between 18,20,22,24px and arial, verdana. I have a newspaper website and would like to change the standard way of wordpress just having one post title font type and size on the front page.

Viewing 2 replies - 1 through 2 (of 2 total)
  • you would need to program this into the front page temaplte (index.php, or loop.php, or content.php, dependant on the theme), into the line of the post title code;

    example built on twenty eleven:

    $font_size = array(18,20,22,24);
    $font_name = array('arial, sans-serif', 'verdana, sans-serif'); ?>
    <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark" style="font-size:<?php echo $font_size[array_rand($font_size)]; ?>px; font-family:<?php echo $font_name[array_rand($font_name)]; ?>;"><?php the_title(); ?></a></h1>


    or similar, you could add random css classes for font and size, and style them in style.css

    The code seems to be working well thank you for the help. However, when reloading the page or returning to the mainpage the headlines change every time, is there a way to make the headlines stays the same when clicking around on the site?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamic post titles on the frontpage’ is closed to new replies.