Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1119362
    pleiades
    Participant

    Hello themeco,
    I am still working on implementing X-theme in our site, and have been beating my head against the wall trying to figure out how to get certain fields to display within certain post types.

    I followed the trail to wp-single.php (single posts, which we are calling “stories” on our site), within the “integrity” framework, which is what we are using. The one line of code that *appears* to pull in the content of the post itself is this:
    <?php x_get_view( ‘integrity’, ‘content’, get_post_format() ); ?>

    But how do I modify what the “content” is to include (and format, i.e. insert HTML before/after) a couple of our Advanced Custom Fields? Where is the presentation of “content” (fields, order, formatting) specified within the X-theme framework? Is there some other page for this that I can locate and copy into our child theme to modify?

    Specifically, we have two fields we want to insert into our Posts: storyteller_name, storyteller_image, and storyteller_bio. These are defined in a field group “Story Archive” in Advanced Custom Fields, and the database is populated with content. We want these fields to appear (with styling) below the post Title; we also want to remove the default fields “post author” and the slashes that appear between post author, categories, comment count. We want to keep the post categories, but have them appear with/below our Custom Fields.

    Thanks for your help or pointing me in the right direction.

    Jen

    #1119852
    Rue Nel
    Moderator

    Hello Jen,

    Thanks for writing in! I am assuming that you are using integrity stack. Because what you are trying to accomplish requires a template customization, we would like to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    After the child theme is set up, please add the following code in your child theme’s functions.php file

    function x_integrity_entry_meta() {?>
      
      <?php // You can display your custom codes here ?>
      <div class="advance-custom-fields">
        <p>You can display the output of your custom fields here!</p>
      </div>
    
    <?php
      //
      // Categories.
      //
    
      if ( get_post_type() == 'x-portfolio' ) {
        if ( has_term( '', 'portfolio-category', NULL ) ) {
          $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
          $separator         = ', ';
          $categories_output = '';
          foreach ( $categories as $category ) {
            $categories_output .= '<a href="'
                                . get_term_link( $category->slug, 'portfolio-category' )
                                . '" title="'
                                . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                                . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                                . $category->name
                                . '</a>'
                                . $separator;
          }
    
          $categories_list = sprintf( '<span>%s</span>',
            trim( $categories_output, $separator )
          );
        } else {
          $categories_list = '';
        }
      } else {
        $categories        = get_the_category();
        $separator         = ', ';
        $categories_output = '';
        foreach ( $categories as $category ) {
          $categories_output .= '<a href="'
                              . get_category_link( $category->term_id )
                              . '" title="'
                              . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                              . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
                              . $category->name
                              . '</a>'
                              . $separator;
        }
    
        $categories_list = sprintf( '<span>%s</span>',
          trim( $categories_output, $separator )
        );
      }
    
      //
      // Output.
      //
    
      if ( x_does_not_need_entry_meta() ) {
        return;
      } else {
        printf( '<p class="p-meta">%1$s</p>',
          $categories_list
        );
      }
    
    }

    Hope this helps.

  • <script> jQuery(function($){ $("#no-reply-1119362 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>