WP move posts to different path
Use the permalinks settings under Settings > Permalinks. They only apply to posts, not to pages. Custom structure: /blog/%postname%/
Use the permalinks settings under Settings > Permalinks. They only apply to posts, not to pages. Custom structure: /blog/%postname%/
You can get the number of posts in the current loop from the $wp_query object. How you do it will depend on whether you use the main loop or a custom one. Main loop Use the global query object. <?php global $wp_query; $is_single_post = ($wp_query->post_count === 1); ?> <?php if ($is_single_post): ?> <div class=”one-post”></div> <?php … Read more
reference WordPress Codex on Templates A quick, safe method for creating a new page template is to make a copy of page.php and give the new file a distinct filename. That way, you start off with the HTML structure of your other pages and you can edit the new file as needed. To create a … Read more
As I understand, the property WP_Post::$ancestors is created dynamically. So, if you try to access to it when it doesn’t exist, PHP calls the magic method __get on that object and try to get the value of that property. Because the property is dinamically created, you can not modify it like you do in this … Read more
There is no theoretical limit on the amount of posts that can be stored and served. However, there will be a limit on what your server can achieve, in terms of database size, hard disk space and processor capacity. On an ordinary dedicated server you should be fine as long a you stick with a … Read more
$last_month = null; while ( $the_query->have_posts() ) : $the_query->the_post(); $the_month = get_the_time( ‘Ym’ ); // e.g. 201611 if ( $last_month !== $the_month ) { if ( $last_month !== null ) { // Close previously opened <div class=”row” /> echo ‘</div>’; } echo ‘<div class=”row”>’; } $last_month = $the_month; ?> <div class=”col-3″> <?php the_title(); ?> </div> … Read more
After setting a taxonomy/post_type you firstly need to flush the rewrite rules. To achieve this you could either run $ wp rewrite flush if you have installed the wp-cli or go to “Settings->Permalinks” and save once. To list a taxonomy in the frontend the url would be example.com/author-team/tom. You could also access the taxonomy url … Read more
Not totally clear what you’re asking, but post_class is probably your best bet. <?php post_class(); ?> More info: https://codex.wordpress.org/Function_Reference/post_class
WordPress always uses the full URL when it inserts a link. There are a number of reasons for this, and they are all good reasons. You can add relative URLs yourself by simply typing your own links and omitting the domain portion of the link. So http://sitename.tld/cool-page becomes /cool-page. As I said, though, this is … Read more
Ever since the solution mentioned here, WP has been updated and now allows you to manipulate the save process of wp_insert_post. If you look at the lines 3035 to 3057 (WP 4.7) the result of the check for empty title and content is stored in $maybe_empty. This variable is then run through a filter called … Read more