$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Pull 2 different custom post type with 2 different WordPress into external website|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Pull 2 different custom post type with 2 different WordPress into external website

matteradmin9PV0评论

I have two different WordPress pages while the main site was developed under Laravel framework. Both WordPress sub-sites have different approach for the main site. It happens that the sub-site #1 was hooked to the main site and it display properly all the blog posts/custom posts. But when I tried to hooked the sub-site #2 to the main site, it still carry the posts of sub-site #1 and/or whenever I tried to set the "post_type" => "page_customs" it don't display the custom post I have there.

Here's the code i have for sub-site #1:

<?php require('site1/wp-load.php');
global $post;

$sticky = get_option( 'sticky_posts' );
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 5 );
$args = array( 'post__in' => $sticky, 'ignore_sticky_posts' => 1, 'posts_per_page' => 5, 'order' => 'DESC' );
$query = new WP_Query( $args );
if ($query->have_posts()) : 
  while ($query->have_posts()) : 
    $query->the_post();

    $field = get_field_object('article_sticky_post');
    $value = $field['value'];
    $choices = $field['choices'];

    if ($value) :
        foreach ( $value as $v ) :
            $set = $v;
        endforeach;

      if($set == 'yes'): ?>

      <div class="listed-type-item _hide">
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?> | <span class="text-success small">Read more...</span></a>
      </div>

      <?php endif; // $set
    endif; // $value
  endwhile; 
endif; 
wp_reset_postdata(); ?>

While here's the code for sub-site #2:

<?php require('site2/wp-load.php');
global $post;

$args = array( 'post_type' => 'nas_customs', 'posts_per_page' => -1, 'order' => 'DESC' );
$query = new WP_Query( $args );
if ($query->have_posts()) :
  while ($query->have_posts()) :
    $query->the_post(); ?>

    <div class="listed-type-item _hide">
      <a href="<?php the_permalink(); ?>"><?php the_title(); ?> | <span class="text-success small">Read more...</span></a>
    </div>

  <?php endwhile; 
endif; 
wp_reset_postdata(); ?>

And it happens that the sub-site #1 content (page title) loads on sub-site #2.

Post a comment

comment list (0)

  1. No comments so far