yoshi
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Gallery – Click on Image to view Next Image? How?<?php // code copied from adjacent_image_link() in wp-include/media.php $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') )); foreach ( $attachments as $k => $attachment ) if ( $attachment->ID == $post->ID ) break; $next_url = isset($attachments[$k+1]) ? get_permalink($attachments[$k+1]->ID) : get_permalink($attachments[0]->ID); ?> <p class="attachment"><a href="<?php echo $next_url; ?>"><?php echo wp_get_attachment_image( $post->ID, 'medium' ); ?></a></p>
This will do.
Forum: Fixing WordPress
In reply to: Why gallery images automatically assign to default category?Attachments are always in the default category, they don’t get assigned to the same category as their parents.
To get the categories of the post that the gallery belongs to, just give the parent’s ID.the_category(',', '', $post->post_parent);
Forum: Fixing WordPress
In reply to: Insert page-specific content & hide in navagationHow about draft/private Post/Page?
They do not appear on menus or search results, and you can use get_posts() with $post_status param to pull the content when you need.Forum: Fixing WordPress
In reply to: Can you Make a Body Background Image Clickable?This is the same idea to Otto’s example – having dummy link covering entire space. I added a few styling to make the main content overlay the link.
#only tested with FF.
body part in html:
<body> <a href="https://example.com" id="bglink">jump to example.com</a> <div id="page"> page contents here </div> </body>
and the stylesheet:
#bglink{ display:block; height:100%; width:100%; position:fixed; left:0; top:0; z-index:0; text-indent:-5000em; /* If you want to make only a part of background clickable, adjust height/width/left/top here. */ } #page { position:relative; z-index:10; }
Personally, I would be very annoyed if I clicked the background without knowing that I’d be sent to somewhere else..
Forum: Plugins
In reply to: How do I limit admin_head content to certain pages?FYI, if you want to include js files in non-plugin pages, you can check against a global variable $pagenow which holds the filename such as ‘post.php’.
Plus,
load-$pagenow
andadmin_head-$pagenow
are also useful action hooks to add processes to a certain page.Forum: Fixing WordPress
In reply to: Attachments links/urls driving me insane!!!!!!Sounds like $post->ID isn’t set correctly.
The code must be placed within the Loop.
If you doecho $post->ID
, does that show the ID of each post?Forum: Plugins
In reply to: Removing the jQuery call from WP Ajax Edit CommentsUse wp_enqueue_script when you use jQuery. This prevents loading the same script multiple times.
Forum: Themes and Templates
In reply to: One button two linksbehavior: url(nikki/wp-content/themes/kn-eng/iepngfix.htc);
A relative path to iepingfix.htc reads different location depending on the page showing.Change it to a absolute path:
behavior: url(/nikki/wp-content/themes/kn-eng/iepngfix.htc);
should fix the problem.Forum: Fixing WordPress
In reply to: previous/next page don’t workOops. That was a Page template.
Then you need to empty
pagename
andpage_id
params otherwise WP looks for a page named ‘artiklar’ and in category 4, which obviously doesn’t exist.<?php query_posts($query_string . '&cat=4&pagename=&page_id='); ?>
Forum: Fixing WordPress
In reply to: Sharing Plugin Folder Between Two or More BlogsAh, second thought. Method #2 wouldn’t work for many plugins. Don’t use.
Forum: Fixing WordPress
In reply to: Sharing Plugin Folder Between Two or More BlogsNever tried myself, and not sure if it’s safe to share the directory but I would try either
1. create a symbolic link to another wp’s plugins directory.
2. or define plugins directory in wp-config.php:define( 'WP_PLUGIN_DIR', '/path/to/wp-content/plugins' ); define( 'WP_PLUGIN_URL', 'https://anotherblog.com/wp-content/plugins' );
Forum: Fixing WordPress
In reply to: previous/next page don’t workWhen you do this, WordPress ignores the other parameters it receives via the URL (such as page number or category). If you want to preserve that information, you can use the variable $query_string in the call to query_posts().
So need $query_string to preserve the paging info.
<?php query_posts($query_string . '&cat=4');?>
Forum: Fixing WordPress
In reply to: Looking to offset “most recent posts”get_posts would be more suitable for that purpose.
The first example in the codex page is exactly what you are looking for.
BTW, get_archives has been deprecated and now we should use wp_get_archives instead.
Forum: Fixing WordPress
In reply to: Attachments links/urls driving me insane!!!!!!'numberposts' => -1,
You are requesting all the attachments the post has. Change this to
'numberposts' => 1,
Forum: Fixing WordPress
In reply to: Attachments links/urls driving me insane!!!!!!'numberposts' => -1,
You are requesting all the attachments the post has. Change this to
'numberposts' => 1,