Horje
Display Post Meta attached to one page, on every page. - Wordpress Solution
Hello, I have some post_meta attached to a homepage.

$meta_boxes[] = array(
	'id'		=> 'menu_tile_one',
	'title'		=> 'Menu Tile One',
	'pages'		=> array('page'),
	'fields'	=> array(


		array(
			'name'             => __( 'Image', 'rwmb' ),
			'desc'  => __( '592px / 900px' ),
			'id'               => "{$prefix}menu_tile_one_image",
			'type'             => 'image_advanced',
			'max_file_uploads' => 1,
			'clone'		=> false,
		)
		

	)
);

I am trying to display this post meta from (page id7) ON EVERY PAGE, not just the page that it is attached to in the admin.

<?php $images = rwmb_meta( 'meta_menu_tile_one_image', 'type=image&size=full');?><?php foreach ( $images as $image ){echo "<img src='{$image['url']}' class='first' alt='' title='' />";} ?>
The above code works on the page that the meta is attached, however it does not work on every page. Any ideas?

Solution - 1

I wonder if you are missing the third input argument, which is $post_id. It's the current post id by default: Example:


$post_id = 7; // You can change this to get_the_ID() as well.
$images = rwmb_meta( 'meta_menu_tile_one_image', 'type=image&size=full', $post_id );


Solution - 2

What is this rwmb_meta function ?


Solution - 3

You need to add the page_id to the rwmb_meta function try this:

<?php 
$images = rwmb_meta( 'meta_menu_tile_one_image', 'type=image&size=full', 7);?><?php foreach ( $images as $image ){echo "<img src='{$image['url']}' class='first' alt='' title='' />";} 
?>





Wordpress

Related
Need some help getting a Jquery library to work - Wordpress Solution Need some help getting a Jquery library to work - Wordpress Solution
BBpress topic freshness function in wp_query. - Wordpress Solution BBpress topic freshness function in wp_query. - Wordpress Solution
List all posts with 2 terms of a taxonomy - Wordpress Solution List all posts with 2 terms of a taxonomy - Wordpress Solution
Table fix - Wordpress Solution Table fix - Wordpress Solution
Merging Terms with Bootstrap Carousel - Wordpress Solution Merging Terms with Bootstrap Carousel - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7