How do I get the category URL from get_the_category?

Use: get_category_link( $category_id ); See: https://codex.wordpress.org/Function_Reference/get_category_link In your specific case: <?php global $post; $categories = get_the_category(); foreach ($categories as $category) : $exclude = get_the_ID(); $posts = get_posts(‘posts_per_page=4&category=’. $category->term_id); foreach($posts as $post) : if( $exclude != get_the_ID() ) { ?> <a href=”https://wordpress.stackexchange.com/questions/219954/<?php the_permalink(); ?>” title=”<?php the_title(); ?>” class=”post c-1″> Link to actual post</a> <?php } endforeach; … Read more

Add menu and submenu in admin with a URL instead of slug?

This is an old post but can’t you just use wordpress $menu and/or $submenu globals like Oleg suggested in number 2. When in doubt copy WordPress: wordpress/wp-admin/menu.php For example to add link this seems like it would work: function add_external_link_admin_submenu() { global $submenu; $permalink = admin_url( ‘edit-tags.php’ ).’?taxonomy=category’; $submenu[‘options-general.php’][] = array( ‘Manage’, ‘manage_options’, $permalink ); … Read more

Post type child of another post type

Attachments are post types someway, when you attach images to a post/page and display them in your post, you get a link like your-post-title/attachment/filename/. Maybe you can create post types with hierarchical option and them filter the link to replace the attachment to post parent name instead.

Prevent WordPress from abbreviating-long-slugs…-in-the-admin

There is a filter at the end of the function: ‘get_sample_permalink_html’. Hook into this and just replace the shortened form with the full length. <?php # -*- coding: utf-8 -*- /* Plugin Name: T5 Unabridge Permalink Slug */ add_filter( ‘get_sample_permalink_html’, ‘t5_unabridge_sample_permalink’, 10, 2 ); /** * Replaces the shortened permalink with its full form. * … Read more

Change slug on post creation

Here is what I did to implement this: function slug_save_post_callback( $post_ID, $post, $update ) { // allow ‘publish’, ‘draft’, ‘future’ if ($post->post_type != ‘post’ || $post->post_status == ‘auto-draft’) return; // only change slug when the post is created (both dates are equal) if ($post->post_date_gmt != $post->post_modified_gmt) return; // use title, since $post->post_name might have unique … Read more

Stop WordPress from reserving slugs for media items?

Thank you for the response everyone. I played around with macemmek’s solution and I think it led me to an even better solution: add_filter( ‘wp_unique_post_slug_is_bad_attachment_slug’, ‘__return_true’ ); That is all that is needed. This will automatically ‘skip’ the default assigned slug on any attachment. So an attachment that might normally get the slug “services” will … Read more

Combining Multiple Taxonomies in one URL

This rewrite rule should work (assuming “brand” and “type” are the taxonomy registered names): function custom_rewrite_rules() { add_rewrite_rule(‘^brand/(.*)/type/(.*)?’, ‘index.php?brand=$matches[1]&type=$matches[2]’, ‘top’); } add_action(‘init’, ‘custom_rewrite_rules’); Remember to flush the rewirte rules after saving this code in your site. Then you will need to hook in several places to fix things. For example, you may need to hook … Read more

Get list of all registered post types slugs

@EAMann’s answer is correct, but there’s already a build in WordPress function for fetching all registered post types: get_post_types <?php // hook into init late, so everything is registered // you can also use get_post_types where ever. Any time after init is usually fine. add_action( ‘init’, ‘wpse34410_init’, 0, 99 ); function wpse34410_init() { $types = … Read more

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