WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Customs Fields syntax in Page of Posts template (3 posts)

  1. JulianRichards
    Member
    Posted 1 year ago #

    I want my site to have two blogs, and it seems that the most efficient way of doing this will be to use Custom Fields to assign each post to one of the two blogs. So I've set up a Custom Field with the key 'type' and the values of either 'blog' or 'work'. Now I want to make page templates to display the posts assigned each of these two values, as suggested at "Example Using Custom Fields". I can't work out which bits of the example code given at that link I need to replace with my own key and value names, though. Maybe I'm being dim, but could someone let me know?

    While I'm here: do I need all the code on that page? it seems there's a lot more than is in the standard page.php file in the TwentyTwelve theme.

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Try changing:

    $args = array(
    	// Change these category SLUGS to suit your use.
    	'category_name' => 'antiquarianism, championship',
    	'paged' => $paged
      );

    to:

    $args = array(
    	'meta_key' => 'type',
            'meta_value' => 'blog'
    	'paged' => $paged
      );
  3. JulianRichards
    Member
    Posted 1 year ago #

    Didn't work, I'm afraid. The code you quote and tweak is from the "Page of Posts" template at http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates, though, not the "Page Of Posts with Custom Fields" version.

    Maybe the answer to my design desire is to have two separate "sites" running under the same domain, with one blog in each, and use a hard-coded header so that the site title and nav look the same everywhere.

Topic Closed

This topic has been closed to new replies.

About this Topic