Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP and wordpress

Featured Replies

I can customise wp and do stuff with the wp functions, but adding custom php is past me

 

I have a template'd post which shows 2 posts on the homepage, using the query posts function.

 

I want to add an advert in between the 2 ads.

 

I have tried a couple of options on google but none work, so need your help guys.

 

I know I will have to do a count++ then do an if statement but I cannot get the right structure,

 

Any ideas?

'in between the 2 ads.' do you mean between 2 posts?

  • Author

'in between the 2 ads.' do you mean between 2 posts?

 

Yup, damn it, example

 

Post

advert

post

Maybe something like that?

<?php if (have_posts()) : ?>
<?php $post = $posts[0]; $c=0;?>
<?php while (have_posts()) : the_post(); ?>

<?php $c++;
if( $c == 1) :?>

<?php the_title(); ?>
<?php the_excerpt(); ?>
<!-- inser your advert here -->
<?php else :?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endif;?>

<?php endwhile; ?>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.