Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpse_210493_apply_advertising_position( &$posts, $return = false ) {
- $ad_posts = array();
- $content_posts = array_filter(
- $posts,
- function ( $post ) {
- $position = get_post_meta( $post->ID, 'rw_adversiting_position', true );
- if ( empty( $position ) ) {
- return true;
- }
- $ad_posts[ intval( $position ) ] = $post;
- return false;
- } );
- $content_posts = array_values( $content_posts );
- ksort( $ad_posts );
- echo "sdfksfkjshdfsdf";
- foreach ( $ad_posts as $position => $ad ) {
- array_splice( $content_posts, $position, 0, $ad );
- }
- if ( $return ) {
- return $content_posts;
- } else {
- $posts = $content_posts;
- }
- }
- ?><pre><?php var_dump( $variable_to_test ); ?></pre><?php
- ?><pre><?php var_dump($ad_posts); ?></pre><?php
- error_log(your-variable-or-whatever);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement