Connect with us

Tips & Tricks

Adding a external file after the first post

Published

on

How might you display a Google ad after the first post or anything you like? It is very simple. You just need to add the variable $loopcounter in the Loop. If the $loopcounter is less than or equal to 1, then include your option. Check out the code:

<?php if (have_posts()) : while (have_posts()) : the_post(); $loopcounter++; ?>

  // your loop

  <?php if ($loopcounter <= 1) { include (STYLESHEETPATH . '/you-file.php'); } ?>

<?php endwhile; ?>

<?php else : ?>

<?php endif; ?>

Pretty simple huh. Well in the $loopcounter line, you may change the include to point to any file or maybe a custom widget like so:

<?php if ($loopcounter <= 1) { dynamic_sidebar( 'Plus Post' ); } ?>

Or use your code directly in between the { & }.

Continue Reading
1 Comment

1 Comment

  1. Pingback: WordPress: Adicionando um arquivo externo após o primeiro Post | DGmike

You must be logged in to post a comment Login

Leave a Reply

Tips & Tricks

Remove spaces when echoing the_title

Ever wanted to print or echo the WordPress title attribute without spaces?

Published

on

This little trick can be useful for calling custom functions and printing the title with out spaces for W3C compatibility. I used this trick in a new theme called Galleria, which will be out for public download in the coming days.

Using this comes in handy for a delicious text link:

<?php $title = get_the_title(); ?>
<a href="http://del.icio.us/post?url=<?php echo $title; ?>&amp;<?php echo str_replace(" ", "%20", $title); ?>">
Bookmark This (<?php echo $title; ?>)</a>

What I am doing is calling $title = get_the_title(); and using str_replace(" ", "%20", $title); to replace empty spaces with a %20, which is used in URL encoding empty spaces.

Alternatively you can use a dash or underscore.

Thanks to Jason Boyle for his adaption.

Continue Reading

Tips & Tricks

Display the_excerpt only if there is text

Have you ever wanted to display the excerpt only if you write one? A simple couple lines of code can display the_excerpt any where you like.

Published

on

In my new theme, I am using this coded trick to display the excerpt on a single post only if I’ve got text inside. Usually if you use the_excerpt and you don’t have one, it will fake one for you.

This is not something that I wanted to do on the single post page. So I used the following code to check if the excerpt existed.

if ( !empty( $post->post_excerpt ) ) :

Once this action is taken into account, you can factor in what code you want to out put if the post_excerpt isn’t empty.

if ( !empty( $post->post_excerpt ) ) :
	the_excerpt();
else :
	false;
endif;

The above code checks if there is an excerpt and print’s it to the screen. If there isn’t an except, it doesn’t do anything.

Continue Reading

Tips & Tricks

Add a shortcode

Published

on

This is a simple one.

/**
 * Your Blog title
 *
 */
function my_blog_title() {
	$blogname = get_bloginfo('name');
    return '<span class="blog-title">' . $blogname . '</span>';
}		  	
add_shortcode('blog-title', 'my_blog_title');

Just add this to your functions.php file and then add [blog-title] in any post or page and it will return your Blog Title. :)

Continue Reading

Random Search Terms

Title

Recent Posts: Fully Net Worth . com

Loren Gray: TikTok Darling Turned Pop Prodigy

Loren Gray: TikTok Darling Turned Pop Prodigy

Introduction: Walk Through the Article In an era dominated by internet influencers and TikTok stars, Loren Gray stands out not just as one of the platform’s top creators but also as an artist who’s taken the music world by storm. Join us as we delve into the life of this multi-faceted talent and trace her […]

Dixie D’Amelio: More than Charli’s Sister – The Star on Her Own Stage

Dixie D’Amelio: More than Charli’s Sister – The Star on Her Own Stage

Introduction: Walk Through the Article While Charli D’Amelio might be the name everyone instantly recognizes, Dixie D’Amelio is forging her path, proving she’s not just “Charli’s older sister.” Join us as we journey through the life, achievements, and secrets of Dixie, the songbird and social media sensation who’s just getting started. Dixie D’Amelio: Bio & […]

Emmanuel Hudson Net Worth.

Emmanuel Hudson Net Worth.

Emmanuel Hudson Net Worth Introduction Emmanuel Hudson is a comedian, an actor, an entertainer, and a YouTube star who is only 29 years old. He first started his career in Atlanta, Georgia. He appeared on national TVseveral times, but the root cause of his success was the video he posted in 2012 on YouTube called […]

Nancy Pelosi net worth.

Nancy Pelosi net worth.

What is Nancy Pelosi’s net worth? Nancy Pelosi is an American politician who has a net worth close to 120 million dollars. In one of her recent disclosure of wealth, Nancy and Paul Pelosi, who is her husband, estimated that their total personal wealth falls somewhere in the range of $43 million to $202 million. […]

Trending