Editor's choice: can't add custom post types

Hi,
The Editor’s Choice area won’t add custom post types.
I am trying to add a few posts from a type I created on Toolset Types, followed the instructions to put their ids, but it didn’t worked.

Do you have any work around for this?

Thanks!

Hello there,

It always display the post unless you edit the code and define your custom post type. To retain the changes when theme update is performed, you’ll need to add the below function to your child theme’s functions.php file.


remove_action('greatmag_before_footer', 'greatmag_editors_choice', 999);
add_action('greatmag_before_footer', 'greatmag_editors_choice_custom');
function greatmag_editors_choice_custom() {
	$title  = get_theme_mod('footer_posts_title', __('Editor\'s choice', 'greatmag'));
	$posts  = get_theme_mod('footer_posts_ids');

	if ( $posts == '' ) {
		return;
	}

        $post_type = 'services';
	$posts = explode(',', $posts);

	$query = new WP_Query( array(
    'post_type'           => $post_type,
		'no_found_rows'       => true,
		'post_status'         => 'publish',
		'ignore_sticky_posts' => true,
		'post__in'			  => $posts
	) );
	if ($query->have_posts()) :
		?>
			<div class="row editor-choice" id="editor-choice">
				<div class="editor-choice-header row">
					<h5 class="editor-choice-title"><?php echo esc_html($title); ?></h5>
					<div class="editor-choice-nav"></div>
				</div>
				<div class="editor-choice-post-carousel">
					<?php while ( $query->have_posts() ) : $query->the_post(); ?>
						<?php if ( has_post_thumbnail() ) : ?>
						<div class="item post">
							<a href="<?php the_permalink(); ?>" class="featured-img"><?php the_post_thumbnail('greatmag-featured-c'); ?></a>
							<div class="this-contents">
								<?php greatmag_get_first_cat(); ?>
								<a href="<?php the_permalink(); ?>" class="post-title-standard"><?php the_title(); ?></a>
							</div>
						</div>
						<?php endif; ?>
					<?php endwhile; ?>
				</div>
			</div>
		<?php
	endif;
}

Define your custom post type slug in this line:


$post_type = 'services';

You can use the functionality plugin like Code Snippets if you don’t have a child theme yet.

Regards,
Kharis