Articles of custom post types

How to create a template to show child terms of a MAIN taxonomy

I’ve registered a custom post type called video, like so: add_action( ‘init’, ‘create_post_type’ ); function create_post_type() { // Videos Post-Type $labels = array( ‘name’ => _x( ‘الحلقات/الأفلام’, ‘post type general name’, ‘qtoon’ ), ‘singular_name’ => _x( ‘حلقة/فيلم’, ‘post type singular name’, ‘qtoon’ ), ‘menu_name’ => _x( ‘حلقات/الأفلام’, ‘admin menu’, ‘qtoon’ ), ‘name_admin_bar’ => _x( ‘حلقة/فيلم’, […]

Change permalink for custom_post_type using custom_post_meta (woocommerce)

I would like to replace the permalink for all products in a woocommerce/wp installation with a custom link, if it set in a custom_post_meta. The custom_post_meta is setup and working fine. From all I have read, the function below should do the trick: function eli_changeProductLink($permalink, $post) { if (‘product’ == $post->post_type) { $custom_url = get_post_meta($post->id, […]

A faster way to query custom post types with multiple conditions?

I am using a lot of custom post types (CPTs) with custom meta and so far I have been using queries like the below, to get for example all events in CountryX that happened in 2014: <?php global $paged; $curpage = $paged ? $paged : 1; $args = array( ‘numberposts’ => -1, ‘post_type’ => ‘event’, […]

Taxonomies not showing up in custom post type

I’ve created the following custom post type: /** * Register hire custom post type */ function hire() { $labels = array( ‘name’ => _x( ‘Hire Products’, ‘Post Type General Name’, ‘fire’ ), ‘singular_name’ => _x( ‘Hire Product’, ‘Post Type Singular Name’, ‘fire’ ), ‘menu_name’ => __( ‘Hire Products’, ‘fire’ ), ‘name_admin_bar’ => __( ‘Hire Products’, […]

Custom post type in theme not appearing

I have a theme on WordPress 4.4 which has this file included in functions.php: <?php function post_types(){ $labels = array( ‘name’ => __( ‘Newsletters’), ‘singular_name’ => __( ‘Newsletter’), ‘menu_name’ => __( ‘Newsletters’), ‘name_admin_bar’ => __( ‘Newsletter’), ‘add_new’ => __( ‘Add New’), ‘add_new_item’ => __( ‘Add New Newsletter’), ‘new_item’ => __( ‘New Newsletter’), ‘edit_item’ => __( […]

Display list of custom post type which match taxonomy

I’m trying to add a snippet in my WordPress sidebar which displays a list of links to posts which match a criteria. I’m using a Custom Post Type cars and a taxonomy car-types and I’d like to display a list of links to cars which are part of the car-types taxonomy. So in short. Display […]

Custom post types, disable fields

I have a plugin that is syncing data from a third party service into a custom post type. The idea is that the post type acts as a slave to the third party service, so any changes there overwrite any on the wordpress site. However there will be a few extra custom fields that will […]

WP_Query get post from a category and from another post type

I have 2 post types (post and help). In post (post type), there is a category named “Hello” and I want to get all posts from the category “Hello” (post_type = post and category_id = 2) and all posts from the post type “help” with a uniq WP_Query. This doesn’t work: $categoryId = 2; $page […]

Template tags to display custom post type posts in category template?

I am developing a custom theme with custom post types involved. Custom post types have been defined via plugin ‘Pods’ ( When writing a category.php, I realized, that the standard loop does not retrieve custom post types (CPT) posts which belong to a certain category. Is that right? If not, are there any template tags […]

archive-{$post_type}.php not loading. instead the default archive.php loads

My has-archive is set to true in the register_post_type. My archive-portfolio.php exists. I’ve tried flushing rewrite rules. I’ve tried a lot of other stuff, and after every step, I reset/saved/resaved/refreshed my permalink structure. This is my register_post_type register_post_type( ‘portfolio’, array( ‘labels’ => array( ‘name’ => __( ‘Portfolio Items’ ), ‘singular_name’ => __( ‘Portfolio Item’ ), […]