Articles of custom post types

pre_get_posts on custom post type

I have a custom post type which displays posts just fine on the page when I use a custom wp_query however, that breaks pagination, so I tried to use pre_get_posts instead as I’m already using that to handle pagination offsets and that works find on normal posts. When I try to use pre_get_posts to set […]

Archive filter disappears on no results?

I have been working through this example: That a colleague of mine found for creating a simple checkbox-based filter for WordPress custom posts, that filters by a custom post type. I’ve got it all set up and it seems to be working here – , if you filter by ‘Place’ then the ‘All Locations’ […]

Why would this IF statement not work?

I’ve placed the following conditional statement in my footer.php file but it isn’t working. I want it to show the footer on every page except for single.php and the services.php template: <?php if (!is_single() || !is_page_template(‘services.php’)) {?> <footer>Content</footer> <?php } ?>

Custom post type table

I am creating a web application and I am using WordPress as the back-end to take care of the database. WordPress has all the functions I require. This is not related to blogging or posting posts. Does anyone know of any solution to create a custom table per custom post type? This is important. The […]

custom post type Search returns No Results in admin panel

I have a custom post type tickets. Here I have some categories. And here is my codes. register_post_type( ‘tickets’, array( ‘labels’ => array( ‘name’ => __( ‘Help and Support’ ), ‘singular_name’ => __( ‘Help and Support’ ) ), ‘public’ => true, ‘has_archive’ => true, ‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘excerpt’, ‘comments’ )) ); […]

Date query for a custom meta field

I would like to use something similar to the following date_query but I would like to use some custom meta fields instead of the existing post columns. For example instead of post_date_gmt I would like to query the meta key date which I have created. In other words, I would like to be able to […]

the_title filter returning wrong post type

I am using the the_title filter to attempt to prepend some text to a custom post type’s title. Our website has several custom post types. Product – slug is eproduct Brand – slug is brand-listing Retail – slug is retail-listing I am trying to prepend a Product’s associated Brand title to the beginning of the […]

How can I show a custom post type for users in the authors.php file?

Here is the code I have. It is showing 100 custom post known as campaigns. I need it to only show the current users. So author/joe should only show joe’s campaigns. <?php if(isset($_GET[‘author_name’])) : $curauth = get_userdatabylogin($author_name); else : $curauth = get_userdata(intval($author)); endif; ?> <h2>Campaigns by <?php echo $curauth->nickname; ?>:</h2> <?php $args = array( ‘posts_per_page’ […]

Need help targeting a custom post type with conditional tags

I found some code online to create content blocks on my WordPress blog. I use a content block at the bottom of the sidebar of my page for a shopping widget. Here’s the relevant code from functions.php: function initialize_content_blocks() { register_post_type(‘content-block’, array( ‘labels’ => array( ‘name’ => ‘Content Blocks’, ‘singular_name’ => ‘Content Block’, ‘add_new_item’ => […]

Hook when adding or editing a specific custom post type?

I’d like to insert a script and if possible some PHP for a custom post type. I’m looking for a hook to do this on the add new or edit screens. Any idea what I’d use for this? I tried “edit_post” but that didn’t seem to work.