How can i list current author’s categories?
try something like this… you need to first call global $post; then get the author id like $author_id = $post->post_author;
try something like this… you need to first call global $post; then get the author id like $author_id = $post->post_author;
I took a long time figure out the right way for this! Here’s what I follow now: Use case: In a plugin’s admin page Hook: admin_print_scripts-<page hook> OR <the php file name for your plugin> $hook = add_menu_page(…) / add_submenu_page(…); add_action(‘admin_print_scripts-‘.$hook, ‘my_callback’); Use case: On all admin pages Hook: admin_print_scripts add_action(‘admin_print_scripts’, ‘my_callback’); Use case: On … Read more
See this famous answer by the equally famous Rarst. Here he charts out the load process of WordPress which hasn’t and isn’t expected to change any time soon. The process pretty much goes: WordPress Core Must-Use Plugins ( mu-plugins directory ) Plugins Themes ( Child before Parent )
We have the following filters added by default (source) add_filter( ‘bloginfo’, ‘wptexturize’ ); add_filter( ‘bloginfo’, ‘convert_chars’ ); add_filter( ‘bloginfo’, ‘esc_html’ ); The bloginfo filter (source) is applied on the get_bloginfo() output, in the display mode, except for the url that has it’s own bloginfo_url filter. The core isn’t using that url filter currently and there’s … Read more
As @StephenHarris pointed out there’s also the pre_get_posts filter. function hwl_home_pagesize( $query ) { if ( is_category( 9 ) ) { // If you want “posts per page” $query->query_vars[‘posts_per_page’] = 1; return; } if ( is_category( ‘movie’ ) ) { // If you want “showposts” $query->query_vars[‘showposts’] = 50; return; } } add_action( ‘pre_get_posts’, ‘hwl_home_pagesize’, 1 … Read more
I’m not 100% sure but I guess it’s because usage of @uses can be covered with @see From phpDocumentor docs @uses is very similar to @see, see the documentation for @see for details on format and structure. The @uses tag differs from @see in two ways. @see is a one-way link, meaning the documentation containing … Read more
The logic on the IF THEN ELSE does seem a bit wonky. If I’m reading it correctly… The call to get_option( $option_name ) will return FALSE if the option does not exist or if it has no value. So the IF would be executed: when the option doesn’t exist and $new_value != FALSE the option … Read more
QUESTION 1 Is it safe to include the assumption that parent themes properly enqueue the child theme styles, from the standpoint of child theme standards? General rule of thumb, yes. But, you should never assume. Most disasters and failures in live are due to assumptions or facts based on an assumption FACTS WITHOUT ASSUMPTIONS A … Read more
(hmm this is somewhat off-topic, but will let others decide on it) Better answer Although it is hard to track official announcement, as @darmb pointed out in the comments there are indications that the official documentation effort is drifting away from the codex in favor of the developer site, and the “make” blogs/sites. So in … Read more
Your condition should be written like this: if (is_page_template(‘path/file.php’)) { // Do stuff } I believe the confusion is a result of two things: The docs refer to “name” ambiguously. Specifying “file name” would make the documentation much more clear. The code behind is_page_template() shows the get_page_template_slug() function at its core. This function actually returns … Read more