ID of Front-Page

This should do the trick. global $wp_query; $post = $wp_query->get_queried_object(); $post->ID; This’ll give you the ID for each page you’re on. get_option( ‘page_on_front’ ) should’ve worked though.

Get post or page id early

For mee it seems that the template_redirect hook worked. Thanks to Pieter Goosen. Heres a solution that should work on earlier hooks: function gdymc_object_exists( $object_id ) { return ( get_the_title( $object_id ) ) ? true : false; } function gdymc_objectID() { if( is_numeric( $_GET[‘page_id’] ) ): $object_id = $_GET[‘page_id’]; elseif( is_numeric( $_GET[‘p’] ) ): $object_id … Read more

pass user id in slug and get user information

The code seems incomplete. Maybe the problem is simply that you define $id but then try to use $user_id? Also, I think id is a protected variable, so maybe use my_id instead. Try this: www.mysite.com/test?my_id=123 $user_id = $_REQUEST[‘my_id’]; $camp_link = get_site_url().”/campaign-detail/?id=”.$user_id; echo “<p class=”campaign_store_name”><a href=””.$camp_link.””>”.$camp_title.”</a></p>”; $arform_id = Get_ARFORM_ID_using_slug($camp_link);

Create unique alphanumeric ID on wp_insert_post

See here the working version // function to save the randomString as custom field value function generate_AlphanumericID( $post_id ) { $postTypes = array(‘profile’, ‘article’); $postType = get_post_type( $post_id ); if (in_array( $postType, $postTypes ) ) { $characters = “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ-_~’!,”; $charactersLength = strlen($characters); $randomString = ”; for ($i = 0; $i < 11; $i++) { $randomString … Read more

custom admin thumbnail for videos, not getting post’s id?

First, you don’t need the apply_filters below. That is called directly from the wp_mime_type_icon() function already. The issue is that your add_filter() call is missing the $accepted_args parameter. The add_filter() function has the following construct: add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) So the $accepted_args is 1 by default. Because of this, only the … Read more

Shortcode for a link and thumbnail

You are assigning the attachment URL to your $url variable: $url = wp_get_attachment_url( get_post_thumbnail_id( $id ) ); then passing that same variable back to wp_get_attachment_url: return ‘<img src=”‘ . wp_get_attachment_url( $url ) . ‘”/><a href=”‘ . get_permalink( $id ) . ‘”>’ . get_the_title( $id ) . ‘</a>’; You should simply output it instead: return ‘<img … Read more

Transient unique names

Transients have practical limitation on key length (45 symbols or something like that), so using dynamic keys tends to come with risk of ending up with keys too long and having it break down. One of common practices is to form unique string (for example combination of plugin name and type of data being saved, … Read more

Add id to menu items in wp_nav_menu

Sounds like you would need to use a Custom Walker Function I’ve found some code on the WordPress Suport Forums which might be of some use: Walker Class – Pastebin class custom_nav_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( “\t”, $depth ) : ”; … Read more

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