Avatar of axessJosh
 asked on

add meta box to select category to select on custom blog page in wordpress

I have created a custom template page in wordpress to display by category type.  I currently create a page for each category i'd like to display in a custom loop.  I'd like to make this a bit more functional for the user allowing them to select which categories display on the page through a custom meta box.

I've been doing some research about adding custom meta boxes to wordpress but want to make sure I'm on the right track.  Is there an easier way to get this accomplished?
WordPressWeb Languages and StandardsWeb Frameworks

Avatar of undefined
Last Comment
Ovid Burke

8/22/2022 - Mon
Ovid Burke

It might be useful to see your custom template to understand what is does and how. How do you currently select what category is displayed on a 'page'?

I've used the following code below.


		global $post;

		$args = array( 'numberposts' => 35, 'category_name' => 'physicians');

		$myposts = get_posts( $args );

		foreach( $myposts as $post ) :	setup_postdata($post); ?>
        	<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

        <?php endforeach; ?>

Open in new window

What i'd like to do is be able to add a meta box in the admin edit screen allowing the user to choose which categories to display on these pages.  This would enable the user to define specific posts in a category to display on this page, and disregard the unselected categories.

we used a custom template by elegant themes at one point that allowed for this but I can't seem to figure how to add this functionality native to wordpress.
Ovid Burke

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck