Визуальный композитор визуализирует цикл - PullRequest
0 голосов
/ 19 февраля 2019

Я добавляю элемент в визуальный композитор, который отображает заголовок и вложенные страницы из родительского элемента с точным идентификатором «127».Каждая переменная отображается правильно, но она была показана неправильно.

Это мой код Последний код: 18 февраля 19
Код обновлен: 19 февраля 19

    <?php
// Create Shortcode parentlink
// Use the shortcode: [parentlink]

if( defined( 'WPB_VC_VERSION' ) ) {

function vc_parent_links($atts) {

  // Attributes
  $atts = shortcode_atts(
    array(
    'sublinks_title' => ''
  ),
    $atts, 'parentlink'
  );
  // Attributes in var
  $sublinks_title = $atts['sublinks_title'];

  // Output Code



$argsvar = array(
    'post_type'      => 'page',
    'posts_per_page' => -1,
    'post_parent'    => '217',
    'order'          => 'ASC',
    'orderby'        => 'menu_order'
 );

$output = "";

$output .= '<h2 style="line-height: 1.2em; text-align: left; letter-spacing:0px;" class="vc_custom_heading">'.$sublinks_title.'</h2>';

$output .= '<section>';

$output .= '<ul class="parent-page">';

ob_start();

$parloop = new WP_Query( $argsvar );

if ( $parloop->have_posts() ) {

      while ( $parloop->have_posts() ) { $parloop->the_post();

        $permanlink = print_r(the_permalink(), true);
        $thetitle = print_r(the_title(), true);

        $output .= '<li><a href="'. $permanlink .'">'. $thetitle .'</a></li>';

      }
}



$output .= '</ul>';

$output .= '</section>';

$output .= '<p>HOLAAAA</p>';



  return $output;

}

ob_end_clean();

add_shortcode( 'parentlink', 'vc_parent_links' );

// Create Submenu list from parent for VC
add_action( 'vc_before_init', 'vc_parent_links_map' );

function vc_parent_links_map() {
  vc_map( array(
    'name' => __( 'Parent Sublinks', 'textdomain' ),
    'description' => __( 'Loads Sublinks from Parent', '' ),
    'base' => 'parentlink',
    'class' => 'sublinks',
    'show_settings_on_create' => false,
    'category' => __( 'Menus', 'textdomain'),
    'icon'    => get_template_directory_uri() . '/includes/images/portfolio.svg',
    'params' => array(
      array(
        'type' => 'textfield',
        'class' => '',
        'group' => __("General"),
        'admin_label' => true,
        'heading' => __( 'Title For Sublinks', 'textdomain' ),
        'param_name' => 'sublinks_title',
        'value' => '',
        'description' => __( 'This will be the title for the Portfolios Files.', 'textdomain' )
      ),
    )
  ) );
}
}// If VC Exist

Дело в том,что цикл выводится за пределы оболочки Heres 2 изображения, чтобы показать вам ошибку https://imgur.com/a/HcV9Yqd https://imgur.com/a/Pa9vA23

VC_Map работает, шорткод рендеринг, что-то происходит с циклом, любой советбыло бы здорово, спасибо.

Отредактировано: Изображение с расширением

!!https://imgur.com/a/wWAv39f
...