Slug for standard post post_type

WordPress offers you the ability to create a custom URL structure for your permalinks and archives. For this you will have to change permalink, Permalinks allows you to choose your default permalink structure. To change permalink go to Settings > Permalinks in WP Backend. Choose Post name In Common Settings Section.

Category and post tag archives do not include posts from custom post type

By default, WordPress will only include the post post type within the post_tag and category taxonomy archives. Use this snippet to add newz posts to the post_tag and category taxonomy archives: add_filter( ‘pre_get_posts’, ‘wpse_newz_taxonomy_archives’ ); function wpse_newz_taxonomy_archives( $query ) { if ( $query->is_main_query() && ( is_category() || is_tag() ) ) { $query->set( ‘post_type’, array( ‘post’, … Read more

How to filter archives both by category and tag?

What you are looking for is a custom search that can be created via rewrite rules. What I’m gonna do is to create a rule that adds some queries to the URL. First, let’s define a rewrite tag so that WordPress recognizes our custom URL. function my_rewrite_tag() { add_rewrite_tag(‘%custom-categories%’, ‘([^&]+)’); } add_action(‘init’, ‘my_rewrite_tag’, 10, 0); … Read more

Customize first page of category

I don´t think you can do this within the template overwrite structure of wordpress but you can include a custom template based on the pagination number. if(get_query_var(‘paged’) == 0){ echo “Include your custom theme here”; }else{ echo “standard”; }

How to get the latest posting time of archived pages in WordPress?

Query the posts ordered by date, restricted to 1 post to display, then get the date. $args = array( ‘posts_per_page’ => 1, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ); $lastpost = get_posts($args); echo $lastpost[0] -> post_date; Edited last line for proper display: $lastpostdate = $lastpost[0] -> post_date; echo ‘<div class=”lastpostdate>”‘ . $lastpostdate . ‘</div>’; Or, … Read more

Change behavior depending on content length

We need two functions in the theme’s functions.php: One function checking the length of the content to adjust the title. Another one to print the formatted post content in case the first function returns TRUE. Let’s start with the first function. This is rather simple because we solved that already. 🙂 if ( ! function_exists( … Read more

How can I organize/create an archive listing by Year and month

function archive_links_custom() { global $wpdb, $wp_locale; $query = “SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type=”post” AND post_status=”publish” GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC”; $arcresults = $wpdb->get_results($query); if ( $arcresults ) { $year = null; foreach ( (array) $arcresults as $arcresult ) { if($arcresult->year != $year) { … Read more

Arrange and separate posts

You can do some tricky thing with PHP. Here is the algorithm you could use. Query posts to get posts as alphabetical order. for/while loop starts. $t = Get first character of the title string. $temp = ” empty string. if $t != $temp echo $t. set $t = $temp. endfor/endwhile. Hope it make sense. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)