Hot answers tagged

20

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


16

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


16

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


9

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


9

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


8

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


8

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


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

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

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

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.


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


7

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


7

Since esc_html_e will escape HTML link (hence will show the HTML anchor as plain text), you'll need to segment the text and escape the non-HTML part with esc_html_e or esc_html__, and print the HTML LINK part without HTML escaping. Method-1 (just for your understanding): You may do it in parts, like this: esc_html_e( 'Dear Guest, with Your information we ...


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

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

You are on right track, with few minor kinks. You need to modify $atts and return it. Any arguments after the first one are provided for information and should not be changed. You need to tell add_filter() that you expect more than one argument. The example with some debug code would be along the lines of: add_filter( 'nav_menu_link_attributes', function (...


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

you can follow the below Steps : Step 1 : In the wp-admin, go to Appearance -> Menus,put the class on the menu item here "CSS Classes (optional)". If you can't see the "CSS Classes (optional)" in the menu item, then there is "Screen Option" in the right top of the screen and there are the options "CSS Class" under "Show advanced menu properties". Step 2: ...


5

I think setting 'publicly_queryable' => false should solve your problem!


5

Run the following when you are changing domain: UPDATE wp_options SET option_value = 'https://yournew.domain' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'https://yournew.domain' WHERE option_name = 'home';


5

The code below should be something similar to what you're looking for Inside the loop template you use for listing blogs (like index.php) you need something like this <a href="<?php the_permalink(); ?>/#respond"> <!-- The blog permalink with the anchor ID after --> <i class="fa fa-comments-o"></i> Leave a Comment </a>...


4

Let's follow the white rabbit. http://core.trac.wordpress.org/browser/tags/3.3.1/wp-login.php#L414 ...can't be changed, it's hardcoded. However it leads to here when clicked: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-login.php#L481 ...which has a wp_signup_location filter for multisite, which in case your site !is_multisite() will never fire ...


4

I know this question was answered years ago, but for those looking for a solution that find this page, there is a MUCH easier solution. Go to Posts > Categories and click on Quickedit for the default blog category called Uncategorized. Rename Uncategorized to Blog and change the slug to blog. Then, when you create new categories, select Blog as the parent ...


4

You can enhance, change the strings to each post title in the table view of backend on post via hook: add_filter( 'post_row_actions', array( $this, 'add_archive_link' ), 10, 2 ); See the result in this screenshot: Below you find my method to add a link /** * Add link on archive * * @uses get_post_type_object, get_archive_post_link, ...


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