get_the_post_thumbnail_url(‘full’) returns empty from custom post type

The first argument for that function is not size. See the documentation (if a function’s not working, checking the documentation should always be your first step): get_the_post_thumbnail_url( int|WP_Post $post = null, string|array $size=”post-thumbnail” ) The first argument is which post the get the URL for, while the size is the second argument. To avoid redundancy, … Read more

how to post default thumbnail if post not created yet

Create “images” folder in current active theme the put “https://wordpress.stackexchange.com/questions/332635/dummy-image-1-1.jpg” in that folder. <?php if ($the_query->have_posts() ) : while ($the_query->have_posts()) : $the_query->the_post(); if ( has_post_thumbnail( ) ) { the_post_thumbnail( ‘full’, array( ‘class’ => ‘mySlides’ ) ); } else { ?> <img src=”https://wordpress.stackexchange.com/questions/332635/<?php echo get_template_directory_uri().”/images/dummy-image-1-1.jpg’; ?>” class=”mySlides” height=”350px”/> <?php } endwhile; else: ?> <img src=”https://wordpress.stackexchange.com/questions/332635/<?php echo … Read more

How to retrieve category of a post in have_post loop?

wp_get_post_categories() and get_category() are specifically for the category taxonomy. You’re using a custom taxonomy, portfolio_cat, so you need to use get_the_terms() to get categories. $categories = get_the_terms( $post_id, ‘portfolio_cat’ ); $cat_str=””; foreach ( $post_categories as $category ) { $cat_str .= $category->name; } If you just want a comma separated list of category links, you can … Read more

Custom post type archive with page as parent url

Yes. First, unregister the post type. (None of the actual data will be deleted if you already have posts.) Then, re-register it with ‘rewrite’ => array(‘slug’ => ‘page-name/custom-post-type-archive’) This will set your archive at the URL you’re looking for, and all the individual CPT posts will be “under” that – i.e. ‘/page-name/custom-post-type-archive/single-title/’.

How to add custom taxonomy in custom post type permalink?

Solution would be a little tricky but you’re on the right path. You need to register taxonomy and post type with dynamic rewrite: function wpse346452_cpt() { register_taxonomy( ‘campaign’, ‘asset’, array( ‘label’ => ‘Campaing’ ) ); register_post_type( ‘asset’, array( ‘public’ => true, ‘label’ => ‘Asset’, ‘rewrite’ => array( ‘slug’ => ‘%campaign_name%’, ), ) ); } add_action( … Read more

Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters

<?php echo substr(get_the_title(), 0,42) ;?> Notice the echo and the get_the_title() This will get you the result you’re looking for. Here’s an alternative to consider: I’ve always found character limits cause weird word breaks that users find confusing. WordPress has a function called wp_trim_words that you can use. <?php echo wp_trim_words( get_the_title(), 5, ‘…’ ); … Read more

Custom Taxonomy Not Showing in Front-End When Outputting a Custom Post Type with WP_Query()

From your explanation above I understood that you want to show custom taxonomy you have registered for that post type. the_category(); fetches the default category that comes with the default post. For rendering custom taxonomy you need to add something like this: $terms = get_the_terms( $post->ID , ‘your custom taxonomy slug’ ); foreach ( $terms … Read more

Show post with thumbnails only

You need to define your arguments before passing to WP_Query. Also, you may use meta_query to acheive what you are looking for. Here is some documentation to help you with your futur developments. WP_Query Link to the documentation Show posts associated with a certain custom field. This part of the query is parsed by WP_Meta_Query, … Read more