appcropolois
  •  Templates
  • Builder
    •  Product Tour
    •  Sign up
    •  Dashboard
  •  Learn
  •  Discover
  •  Upgrade
  •  Sign in
  •  My Profile
    • View Orders
    • Edit Profile
    • Sign Out
  •  Cart
    ➜ 
  1. Home
  2. Learn
  3. Accessing Post and Pages ...
Share

Accessing Post and Pages Custom Fields

If you know the ID of post or page you can access the custom fields by using the {meta...} tag:

1
2
3
{meta post_id="23" assign_to="custom_fields"}
 
{dump var="custom_fields"}
{meta post_id="23" assign_to="custom_fields"}

{dump var="custom_fields"}

This should output an array similar to the one below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
array(6) {
  ["success"]=>
  bool(true)
  ["message"]=>
  string(7) "success"
  ["action"]=>
  string(14) "appc_post_meta"
  ["route"]=>
  string(14) "appc.post.meta"
  ["post_id"]=>
  string(3) "513"
  ["data"]=>
  array(5) {
    ["_edit_lock"]=>
    string(13) "1431444730:11"
    ["_edit_last"]=>
    string(2) "11"
    ["_thumbnail_id"]=>
    string(3) "509"
    ["_wp_page_template"]=>
    string(7) "default"
    ["icon"]=>
    string(32) "/resources/img/features-ico2.png"
  }
}
array(6) {
  ["success"]=>
  bool(true)
  ["message"]=>
  string(7) "success"
  ["action"]=>
  string(14) "appc_post_meta"
  ["route"]=>
  string(14) "appc.post.meta"
  ["post_id"]=>
  string(3) "513"
  ["data"]=>
  array(5) {
    ["_edit_lock"]=>
    string(13) "1431444730:11"
    ["_edit_last"]=>
    string(2) "11"
    ["_thumbnail_id"]=>
    string(3) "509"
    ["_wp_page_template"]=>
    string(7) "default"
    ["icon"]=>
    string(32) "/resources/img/features-ico2.png"
  }
}

Here is a complete example that show how to request children pages and their custom fields meta data:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{pages child_of="content-features" assign_to="features_pages"}
<div id="features">
    <div class="container">
        <div class="section_header">
            <h3>Features</h3>
        </div> 
        
        {foreach $features_pages.data as $feature}
        {meta post_id="{$feature.ID}" assign_to="meta"}
        {dump var="meta"}
        <div class="row feature">
            <div class="col-sm-6 {if $feature@index%2 == 1}pic-right{/if}">
                <img src="{$feature.post_thumbnail}" class="{if $feature@index%2 == 1}pull-right{/if} img-responsive" alt="{$feature.post_thumbnail}"/>
            </div>
            <div class="col-sm-6 info{if $feature@index%2 == 1}-left{/if}">
                <h3>
                    <img src="{$meta.data.icon}" />
                    {$feature.post_title}
                </h3>
                {$feature.post_content_filtered}
            </div>
        </div>
        {/foreach}
    </div>
</div>
{pages child_of="content-features" assign_to="features_pages"}
<div id="features">
    <div class="container">
        <div class="section_header">
            <h3>Features</h3>
        </div> 
        
        {foreach $features_pages.data as $feature}
        {meta post_id="{$feature.ID}" assign_to="meta"}
        {dump var="meta"}
        <div class="row feature">
            <div class="col-sm-6 {if $feature@index%2 == 1}pic-right{/if}">
                <img src="{$feature.post_thumbnail}" class="{if $feature@index%2 == 1}pull-right{/if} img-responsive" alt="{$feature.post_thumbnail}"/>
            </div>
            <div class="col-sm-6 info{if $feature@index%2 == 1}-left{/if}">
                <h3>
                    <img src="{$meta.data.icon}" />
                    {$feature.post_title}
                </h3>
                {$feature.post_content_filtered}
            </div>
        </div>
        {/foreach}
    </div>
</div>

By: Raul Sanchez
Category: Frameworks
Posted on: Tuesday, May 12, 2015

Sign in to post your comment


Not registered? Create an Account.

Lost your password? Click here to recover.

Building Apps?

Create, customize, and publish mobile web applications using the Appcropolis Mobile Builder.

Get Started
Browse Categories
  • Books (0)
  • CSS3 (2)
  • Design (0)
  • Frameworks (10)
  • How-To (6)
  • HTML5 (2)
  • jQuery Mobile (7)
  • Miscelaneous (1862)
  • Mobile Builder (1)
  • News (9)
  • Opinion (1)
  • User Experience (0)
  • Web Technology (11)
  • Webclips (4)

Ready-to-use Templates

Check out Appcropolis Mobile Templates

We offer 1,000's of mobile templates that are fully designed, coded, and ready to use. Learn more.

Download Free Templates

Contact Us

Your feedback means the world to us.
Contact us if you have any questions or
any feature requests:

Saint Louis, MO 63101
911 Washington Ave
Email: info@appcropolis.com

Appcropolis

  •   About Us
  •   Blog
  •   Discover
  •   Templates
  •   Contact Us

Get Free Templates

Subscribe to our newsletter to receive
notification about new templates, prodcut updates,
and technical articles.


© 2025 Appcropolis, LLC · All Rights Reserved
Sitemap  ·  Terms Of Service  ·  Privacy