custom post type archive page url to point to Page permalink

You have multiple options here. 1. Define post type archive slug on post type registration By setting ‘has_archive’ => ‘galleries’ you can define custom post type archive slug. Check documentation. Then you can delete your page “galleries” then add & customize the archive-post_type.php 2. Disable default archive for post type Disable the archive by setting … Read more

Dynamic navigation for custom post type (pages)

The wp_list_pages() function calls get_pages(), which can’t be easily overridden with a different post type. Here’s a basic modification of that function which calls get_posts() instead. This takes basically the same arguments as wp_list_pages, with one additional: *post_type* (set as the name of your post type). function wp_list_post_types( $args ) { $defaults = array( ‘numberposts’ … Read more

Retrieve single term slug

Thank you guys for such quick response. Much appreciated! Here is code for “global” Tags page (displaying terms of default ‘post_tag’ taxonomy): <?php $term_slug = get_queried_object()->slug; if ( !$term_slug ) return; else $loop = new WP_Query( array( ‘post_type’ => ‘any’, ‘tag’ => $term_slug, ‘posts_per_page’ => 10 ) ); while ( $loop->have_posts() ) : $loop->the_post(); ?> … Read more

Filter by custom Field for Custom post type Admin Listing

I had to modify max answer to get the filter working. Renaming the select to issue_restrict_articles stopped it incorrectly filtering & kept the filter controls on the screen. posts_where filter and a SQL query to actually filter. function restrict_articles_by_issue() { global $wpdb; $issues = $wpdb->get_col(” SELECT DISTINCT meta_value FROM “. $wpdb->postmeta .” WHERE meta_key = … Read more

How do I programmatically add items of content to a custom post type?

You should first run the wp_insert_post() which will return the post ID. Then use that post ID to add your custom fields. Use add_post_meta() to add the custom fields. $post_id = wp_insert_post( $args ); add_post_meta( $post_id, ‘longitude’, $my_long ); add_post_meta( $post_id, ‘latitude’, $my_lat ); For image attachments, you can refer to this question: How to … Read more

Adding custom post type to loop

You need something like this in you functions.php file, I’m using the action Pieter suggested. function add_custom_post_type_to_query( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘post_type’, array(‘post’, ‘article’) ); } } add_action( ‘pre_get_posts’, ‘add_custom_post_type_to_query’ ); You can read more about the pre_get_posts in the docs.

Custom post type metabox array

Your code make no sense, anyway here is a nice way to do it and you get: function Print_price_fileds($cnt, $p = null) { if ($p === null){ $a = $b = $c=””; }else{ $a = $p[‘n’]; $b = $p[‘d’]; $c = $p[‘p’]; } return <<<HTML <li> <label>Nr :</label> <input type=”text” name=”price_data[$cnt][n]” size=”10″ value=”$a”/> <label>Description :</label> … Read more