Hot answers tagged

21

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


19

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


18

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


13

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


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

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.


9

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


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

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


8

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


7

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


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

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

You're probably getting that error because WordPress doesn't have the $wp_rewrite global loaded yet for some reason. Either something deactivated it, or you're trying to run those functions before WordPress has a chance to load it. If you're trying to do this in a plugin or in your theme's functions.php file, make sure you're inside a function that is ...


6

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


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


5

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


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

if anyone comes across with this issue, I resolved it by editing both the 'home' and 'siteURL' fields in the wp-options table of the database on the server (not the localhost one) to replace the 'localhost/wordpress' with 'http://www.youehostedsitename'. replace Both 'home' and 'siteurl'.


5

I found a solution based on the code of this page: https://core.trac.wordpress.org/ticket/22180 All attachment files have a post status of 'inherit'. So first you need to add "inherit" as one of the possible post status to search for. You can use the wp_link_query_args filter to do that. function my_wp_link_query_args( $query ) { if (is_admin()){ ...


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


5

Ok I came up with this add_action( 'wp_loaded', 'my_create_questionnaire_link'); function my_create_questionnaire_link(){ // this check is for demo, if you go to http://yoursite.demo/?create-my-link, you will get your unique url added to your content if( isset( $_GET['create-my-link'] ) ){ // This filter is for demo purpose // You might want ...


5

Yes, it is possible. You can do this with ajax call that updates post meta field before the link is followed. In the example, I used admin and non-admin users who click the link and automatic increase link_check_click_counter in the post meta. I used here the example to show the data using wp_footer. You can also use wp_head instead of wp_footer. Copy and ...


4

You can get the current language with qtranslate using the function qtrans_getLanguage(); and then use it like this for conditionally showing content: <?php if ( qtrans_getLanguage() == 'en' ) { //put your code in here } elseif ( qtrans_getLanguage() == 'de' ) { //put your code in here } ?>


4

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


4

You can use the Search Regex plugin. This will allow you to create a regular expression to intelligently search and replace across all of your posts. After you activate the plugin, go to Tools, Search Regex. If you want to remove all links to http://example.com, here is one regular expression you could try: /<a href="http:\/\/example\.com[^>]*>([...


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