Add parent post to Custom Post Type [closed]
Setting the hierarchical property of the post type to true let’s you set parent posts for them: ‘hierarchical’ => true,
Setting the hierarchical property of the post type to true let’s you set parent posts for them: ‘hierarchical’ => true,
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
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
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
(Revised to improve the wording) Actually, you do not have to set the orderby to post__in for post__in query to work. There’s no such limitation in WordPress and you’d only need to set ‘orderby’ => ‘post__in’ when you want to sort the posts exactly in the same order as the post IDs in the post__in … Read more
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/’.
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
<?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
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
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