Include Post Format in permalink

While researching this topic myself, I found a plugin called Post Format Permalink. However, this plugin is not compatible with recent versions of WordPress; it is also filled with unnecessary code. I forked the plugin’s repository on GitHub, and improved the code greatly. I can now use a %post_format% tag in my permalink structure, and … Read more

How to recognise on which site the content is being rendered?

You can use the global $template. The following function returns the basename of the template file being used: index, archive, etc. function get_template_name_wpse_85011() { global $template; $filename = basename( $template, ‘.php’ ); return $filename; } And use it in your template with something like: $templat = get_template_name_wpse_85011(); switch( $templat ) { case ‘index’: // do … Read more

Registering different Post Formats for Blog Post and CPT

I found an alternative approach. There is a unique class in body tag for each post type. e.g for portfolio post type i can use the CSS code something like mentioned below to hide the extra option. .post-type-portfolio #post-format-audio, /* for radio button itself */ .post-type-portfolio .post-format-audio /* for option label */ { display: none; … Read more

WordPress add post format support not working

Add this to your child theme which over-rides what your parent theme supports. Post Formats for Posts add_action( ‘after_setup_theme’, ‘wpsites_child_theme_posts_formats’, 11 ); function wpsites_child_theme_posts_formats(){ add_theme_support( ‘post-formats’, array( ‘aside’, ‘audio’, ‘chat’, ‘gallery’, ‘image’, ‘link’, ‘quote’, ‘status’, ‘video’, ) ); } And here’s the result tested on the Twenty Twelve default theme. You can also use the … Read more

WordPress export tool doesn’t export post-format value of custom post type?

After spending time debugging export.php, I found that we have to register post_format taxonomy for our custom post type. register_taxonomy( ‘post_format’, ‘portfolio’, array( ‘public’ => true, ‘hierarchical’ => false, ‘labels’ => array( ‘name’ => _x( ‘Format’, ‘post format’ ), ‘singular_name’ => _x( ‘Format’, ‘post format’ ), ), ‘query_var’ => true, ‘rewrite’ => $rewrite[‘post_format’], ‘show_ui’ => … Read more

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