SHARE
TWEET

Untitled

a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function wpse_210493_apply_advertising_position( &$posts, $return = false ) {
  2.     $ad_posts = array();
  3.  
  4.     $content_posts = array_filter(
  5.         $posts,
  6.         function ( $post ) {
  7.             $position = get_post_meta( $post->ID, 'rw_adversiting_position', true );
  8.  
  9.             if ( empty( $position ) ) {
  10.                 return true;
  11.             }
  12.  
  13.             $ad_posts[ intval( $position ) ] = $post;
  14.  
  15.             return false;
  16.         } );
  17.  
  18.     $content_posts = array_values( $content_posts );
  19.  
  20.     ksort( $ad_posts );
  21.  
  22.     echo "sdfksfkjshdfsdf";
  23.  
  24.     foreach ( $ad_posts as $position => $ad ) {
  25.         array_splice( $content_posts, $position, 0, $ad );
  26.     }
  27.  
  28.     if ( $return ) {
  29.         return $content_posts;
  30.     } else {
  31.         $posts = $content_posts;
  32.     }
  33. }
  34.      
  35. ?><pre><?php var_dump( $variable_to_test ); ?></pre><?php
  36.      
  37. ?><pre><?php var_dump($ad_posts); ?></pre><?php
  38.      
  39. error_log(your-variable-or-whatever);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top