Tag Info

Hot answers tagged

13

admin_url() gets you the correct administration page URL (and network_admin_url() to get a network administration page URL) Optionally, you can use add_query_arg() to append arguments to an URL, using an associative array: $page = 'edit_record_page'; $rec_id = 1; $record_url = add_query_arg(compact('page', 'rec_id'), admin_url('admin.php'));


10

Admin Dashboard -> Appearance -> Menus If the theme is WP 3.0 ready, you will have an option to add a custom link (ie external link) on the left side, and you can drag and drop it into the order you want. Justin Tadlock wrote an awesome post about 3.0 menus - http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus If your theme isn't ...


9

you may try to add this to your .htaccess : <FilesMatch "\.(?i:pdf)$"> # Force File Download ForceType application/octet-stream Header set Content-Disposition attachment </FilesMatch>


8

<?php global $current_user; get_currentuserinfo(); echo get_author_posts_url($current_user->ID); ?>


8

Go to-> http://yourblog.com/wp-admin/options.php Search for: image_default_link_type Change Value to: none (available options are none, file [links to the file itself], post [links to the post the image is related to], attachment [links to the attachment page with the image on it])


8

All you need to do is a simple call in your functions.php: add_action( 'wp_enqueue_scripts', 'add_thickbox' ); That’s it. WordPress will now enqueue jQuery and the thickbox script. By default, linked images aren’t thickboxy yet. You need to: Add a class thickbox to the links manually/per PHP, or Use a second script to add these classes automagically. ...


6

Per default wp_list_comments() calls the class Walker_Comment. Its method start_el() calls edit_comment_link() and here we find a filter for your question: It is called 'edit_comment_link' and it passes two variables, the link text and the comment ID, which we can use. The URLs to mark a comment as spam or to delete it are: ...


6

I tried for a bit and could not get this to work perfectly, but it's close, it's hard to extend with the <form> for the popup styles being hardcoded, thought possible with more work. To get started you can: Enqueue the link popup javascript and styles, the main .js file is wp-includes/wplink.js. Depending on where you loading this you might need to ...


6

These can be nicely done with WordPress using custom post type for link submission, so then the rest becomes very easy using a few plugins: Voting - CMS Vote Up Social CMS News will handle the voting. Easy link submission - simple custom front end post form would do the job (ex: here or you can use plugins like Mini TDO, Gravity forms... Member creation ...


6

You can do a query like: SELECT ID, post_title, post_date, post_content FROM wp_posts WHERE post_content LIKE '%your-post-title%' ORDER BY post_date to get all posts that linked that old post order by date.


6

After reading this thread I saw that I might need this also sometimes. So here is the result: The internal link checker plugin It adds a meta box at your post edit screens that shows links to all posts who link internally to the currently displayed post. If you want to alter the output (add something for eg.), please use the provided filter. An example of ...


6

If anybody is interested in do the trick, my solution is this: function remove_media_link( $form_fields, $post ) { unset( $form_fields['url'] ); return $form_fields; } add_filter( 'attachment_fields_to_edit', 'remove_media_link', 10, 2 );


6

get_adjacent_post(), which is used by all functions that return a (link to) the next or previous post, only has a $in_same_cat argument, which looks at the categories the post is in, not the tags. You could hook into the get_[next|previous]_post_join to modify the join query for your call, but then it's probably easier to copy the function, remove the ...


5

If you don't mind all PDF attachments been forced to be downloaded then you can use something like this: <?php if (have_posts()) : while (have_posts()) : the_post(); $pdf_title = $post->post_title; $uploads_dir = wp_upload_dir(); $attachment_src = get_post_meta( $post->ID, '_wp_attached_file', true ); $pdf_src = path_join( ...


5

I'll answer your question below, but have you looked at using embeds? Look here for more information: http://codex.wordpress.org/Embeds The simplest regex for this would look something like http\:\/\/.*\b Here's an example of it in action: <?php $file = 'test.txt'; $fp = fopen($file, 'r'); $contents = fread($fp, filesize($file)); $matches = ...


5

It depends on your theme and WP version (you're using 2.9.1 - you should consider upgrading). You can: upgrade to V3+ to use the menu editor that's built in (recommended) more info: http://templatic.com/news/wordpress-3-0-menu-management hard code your theme template with the link added to the end in the HTML modify the theme call to wp_list_pages() ...


5

Blogs of a few core committers and regular core contributors you've missed: http://andrewnacin.com (andrew nacin, committer) http://dd32.id.au (dd32, committer) http://scribu.net (scribu, committer) http://austinmatzko.com (filosofo) http://hakre.wordpress.com (hakre) http://www.miqrogroove.com (miqrogroove) http://www.semiologic.com (myself, though I ...


5

$my_url = 'my/relative/url.php'; echo site_url($my_url); site_url() when used by itself will return the absolute path to your blog. But, if you add an argument to it, as per my example above, it will prepend the absolute path to your path. Just make sure your URL doesn't contain a leading slash (eg: /this/may/not/work). Finally, if you happen to have your ...


5

This is not able to be changed through a filter. In WordPress 2.9.2 and lower, the setting can be changed in /wp-admin/options.php. The image_default_link_type field is set to "file" by default. If you set it to "none", then scroll to the bottom and save, it will disable media links. This option has been removed from options.php in WordPress 3. For ...


5

Short answer: get_previous_posts_page_link is the function you want: <?php if($url = get_previous_posts_page_link()): ?> do stuff with $url <?php endif; ?> Longer answer: follow the code. previous_posts_link calls get_previous_posts_link. <?php /** * Display the previous posts page link. * * @since 0.71 * @uses ...


5

In short YES, they could have. As anything else could have been implemented as custom post type and/or custom taxonomy. But WordPress is a grown system - now 9 years old - and things are moving slowly to keep most stuff backwards compatible. In short, with WP 3.5, the Links Manager will be moved to a plugin, as you can read in the trac ticket.


5

Well, started as a curiosity, ended up doing a plugin... : After finishing, I went to look in WordPress repository and...yes, there's already one that does it: Easy Blogroll Image : At least, I took a different approach and did something different. Featured Link Image - [edit: released in the WordPress repository, link updated]


5

Why not do a one-to-one redirect? When migrating the data over, add a custom field like '_legacy_url' in the WXR or whatever mechanism you're using to track the old URLs. Then, check during the template_redirect action for a one-to-one match whenever WP throws a 404. add_action('template_redirect', 'typepad_redirects', 0); function typepad_redirects(){ ...


4

WordPress has a built-in function for removing protocol and domain from absolute URLs, wp_make_link_relative, located in /wp-includes/formatting.php: function wp_make_link_relative( $link ) { return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link ); } To apply this function to (e.g.) permalinks, simply add a filter, as such: add_filter( ...


4

I decided to use this, which is based on @AndresYanez's answer: function get_image_id_by_link($link) { global $wpdb; $link = preg_replace('/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $link); return $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE BINARY guid='$link'"); } This is much more succinct (since it doesn't jump through the ...


4

Add that to your functions.php: function wp_link_query_mod ( $results ){ if( count( $results ) ){ for( $i=0; $i<count($results); $i++ ){ $results[$i]['permalink'] = wp_get_shortlink( $results[$i]['ID'] ); } } return $results; } add_filter('wp_link_query', 'wp_link_query_mod'); This hook is only usable since WP ...


4

To list all pages with title and permalink from one user you need $wpdb->get_results(). The following code is based on this answer: How to count current user's pages? First, we move the counter into a separate helper function; we might need it later again: /** * Get all post IDs and titles of a type for a user. * * @param int $user_id * @param ...


4

Use the function make_clickable(): $text = get_post_meta( get_the_ID(), 'my_key', TRUE ); echo make_clickable( $text );


4

No, there is no "full archive" page like you describe created by default. This would basically be the twentyten index page set to display "your latest posts." If you don't want to access the archives via some sort of filter (category, author, year, month etc.) then you will need to create your own archive template and page like you described above. you could ...



Only top voted, non community-wiki answers of a minimum length are eligible