register_post_type permalink

You have to use post_type_link filter. Create a handler to handle this filter, you can create $permalink as per your need there. In addition to this, you may have to use “pre_get_posts” action also. I used both these couple of months ago, I created permalinks to show as cpt_name/post_name.

Bolding several words at once

This is a neat idea that I think I may use too. Here’s the solution I’ve just cooked up. First, add the following to your functions.php file: /* BOLDED CONTENT */ // Affect the content after it’s retrieved and before it’s displayed add_filter( ‘the_content’, ‘bolded_content’ ); function bolded_content( $content ) { // Look for custom … Read more

posts_per_page returning only one post

You may please update your code as follows function blog_post_home_shortcode() { $query = new WP_Query( array( ‘post_type’ => ‘post’, ‘order’ => ‘DESC’, ‘post_status’ => ‘ publish’, ‘posts_per_page’ => 3 )); while ($query->have_posts()): $query->the_post(); $blog = get_the_title(); echo $blog; endwhile; wp_reset_postdata(); } add_shortcode(‘blogs_home’, ‘blog_post_home_shortcode’); Please check the above code and let me know if it works … Read more

How to display post title inside thumbnail?

Think this should do it… (there are hundreds of ways to achieve this) <?php // Display blog posts on any page @ https://m0n.co/l $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query(‘posts_per_page=5’ . ‘&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail … Read more

Using wp_tag_cloud with only posts published in specific year

All you can do is to find the post from current year and filter out the tags from those posts. Please see the code below, $getdate = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $getdate[“year”] ), ), ); $query = new WP_Query( $args ); $years_tag = array(); if ( $query->have_posts() ): while … Read more

Assigning Two Different Post Dates For Single Post

Have you tried the basic Custom Fields that WordPress includes automatically? If you don’t see it at the bottom of your Post edit screen, click the Screen Options button at the top-right of your editor window and check the box next to Custom Fields to make it visible. Once you can see it at the … Read more

get_children returns older images

Your problem is here: ‘order’ => ‘ASC’, ‘numberposts’ => ‘-1’, ‘orderby’ => ‘menu_order ID’)); You asked for them to be ordered by menu order, then ID. Then you asked for them to be given in ascending order. Since newer posts have higher IDs than older posts, older posts get shown first. Flip the ASC to … Read more

My Custom Post Type Still Using index.php

It looks like your theme is missing certain key files that are needed in order to keep WordPress from defaulting to index.php per the WordPress Template Hierarchy. Since you have defined your portfolio post type to act like posts by setting ‘hierarchical’ to false, you should probably be using the post custom template files. In … Read more

Using wp-cli and delete everypost first image

According to the WP-CLI docs for the wp search-replace command (and wp db search, for that matter), you have to pass your search string without delimiters and pass any flags separately. Instead of: wp search-replace ‘/<img[^>]+\>/i’ ” wp_posts –regex –allow-root You would use something more like this: wp search-replace ‘<img[^>]+\>’ ” wp_posts –regex –allow-root –regex-flags=”i” … Read more