Hot answers tagged

19

One option is to add a class to the Styleselect menu in MCE. Adapted from the "TinyMCE Custom Styles" Codex page you first need to add the style select to the editor: // Callback function to insert 'styleselect' into the $buttons array function my_mce_buttons_2( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } // Register ...


18

The dialog HTML comes from WP_Editors::wp_link_dialog() but no hooks in there. We could instead use jQuery to append the custom HTML to the link dialog and try to override e.g. the wpLink.getAttrs(), because it's very short ;-) Demo example: jQuery( document ).ready( function( $ ) { $('#link-options').append( '<div> <...


15

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 ...


14

You can use something like this to get the parent page URL (and show its page title): <?php if ( $post->post_parent ) { ?> <a href="<?php echo get_permalink( $post->post_parent ); ?>" > <?php echo get_the_title( $post->post_parent ); ?> </a> <?php } ?> If you are running this code outside of the loop (...


10

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]) or set it in your functions.php via (same options available as mentioned ...


8

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


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. ...


8

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 ...


8

It's not built into core, but it's certainly possible to add, however - I wouldn't consider it a good idea to have a single post available at multiple URLs, so a redirect is probably best. Of course, it will require a bit of PHP, as WordPress doesn't operate on magic or willpower. First, we hook a function to the parse_request action, which runs when ...


7

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 );


7

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 ...


7

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: wp-admin/comment.php?c=1&...


7

It's commonly activated through: add_filter( 'pre_option_link_manager_enabled', '__return_true' ); The suggested Link Manager plugin only contains this code line.


7

My issue is resolved, i am posting this as an answer so that someone else can benefit out of it. My issue was, siteurl and homeurl were not updated, so i have placed define('RELOCATE',true); in my wp-config.php file. And again tried to access the website , it gone to the correct url but all the css was gone. Then i headed over to wp-admin and it also came ...


7

I had the same problem (works fine now), here is what i done instead of try to access to the admin panel whit yoursite.com/wp-admin i tried with yoursite.com/wp-login.php and it took me to the admin panel of my new site. Then I changed the site domain in general settings and now it works just fine.


7

There is not ethical way of doing this. But still there is a way to do this. WordPress wrote wpLink script keeping in mind that editor is there but still WordPress handle when editor is not there (Good Thing) Consider this example and assume that we are using it on front-end in footer. First enqueue the essential style and scripts. function ...


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

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

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( '...


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 and ...


6



6

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 ...


6

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.


6

I suggest making it private ('public' => false when registering the post type). You could club it with 'show_ui' => true to still display the admin interface. See the codex for register_post_type for full reference http://codex.wordpress.org/Function_Reference/register_post_type


6

I've created these two functions you may use to add custom items to a given menu item present in your menu (page, post, link...). In your case, you can add these function to your functions.php and call them like this: $menu_name = 'Your Menu Name'; $name_of_menu_item_to_append_to = 'My Account'; $id_of_menu_item_to_append_to = get_wp_object_id( $...


6

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 3.7,...


6

The HTML for the inserted internal links are generated by Javascript, so I'm not aware of any easy way to change it. The HTML generation is controlled from the wpLink.htmlUpdate method (HTML mode) and the wpLink.mceUpdate method (TinyMCE mode), in the /wp-includes/js/wplink.js file. Here are some ideas: Add a query parameter to the inserted links: We ...


6

These options are hardcoded into the tmpl-attachment-display-settings Underscore media template in the /wp-includes/media-template file: <script type="text/html" id="tmpl-attachment-display-settings"> <h3><?php _e('Attachment Display Settings'); ?></h3> ...cut... <select class="link-to" data-...


6

Within each menu item, object_id holds the ID of whatever object the menu item refers to. This will be a post / page / CPT / term ID. If it's a custom link, the ID refers to itself. (If you want to know what type of object it is, object contains that.) get_queried_object_id() will give you the ID of the current page. We can use the API function ...


6

Assuming you're using wp_nav_menu() to display your navigation you could apply a walker that looks for css classes: $items_wrap = '<nav class="...">'; $items_wrap .= '<ul id="%1$s" class="%2$s">%3$s</ul>'; $items_wrap .= '</nav>'; wp_nav_menu( array( 'container' => false, 'container_class' => false, '...


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