Tag Info

Hot answers tagged

4

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


4

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


3

Filter kses_allowed_protocols (wp-includes/functions.php wp_allowed_protocols) to add your protocol: add_filter( 'kses_allowed_protocols', function( $protocols ) { $protocols[] = 'weixin'; return $protocols; }); The default values are 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', ...


3

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


3

The sidebar description runs through esc_html(), so you cannot pass HTML directly. But you can use the filter esc_html to insert your desired content. Here is a simple example: add_action( 'widgets_init', function() { $desc = "Read the <a href='http://wordpress.stackexchange.com/q/189749/73'>explanation</a>!"; $placeholder = ...


2

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


2

You may use this plugins else you can even create a page with all pdf link to download it. Google Sitemap Generator Sitetree


2

WordPress is strongly opinionated about using absolute URLs. Doesn't mean it's better but it's a choice is makes. The common way to handle it is replace as necessary in database. Please note that if you run replacement on all of database it is extremely important to use serialize–aware tool, or you risk corrupting the data.


2

I usually use tool like this: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ This takes care of any serialized data and can be used to change out staging data from the entire database, not just the post content. Typically a search and replace will look like this: find = staging.site.com and replace with = www.site.com. This ...


2

next_post_link() actually creates an anchor tag, not just the URL. Try something like below to just get the URL: <?php echo get_permalink(get_adjacent_post(false,'',true)); ?>


2

The plugin you mentioned is only a single function so it shouldn't be too heavy on your setup. It uses the comments_template filter to inject the pingbacks/trackbacks list into your page. But the plugin is using an extra manual SQL query and the template is constructed by hand, so there's a room for improvements/simplifications. A simple demo plugin with ...


2

wp_rel_nofollow() add nofollow attribute to all links so we can not use it or may be I am not sure how. You can use this function to add rel="nofollow" to all external links. This function will check all links in content against your blog/website URL (as internal domain) and add nofollow attribute if both does not match. function ...


1

Based on @Robert hue's answer and the wordpress functions wp_rel_nofollow() and wp_rel_nofollow_callback I came up with this very similar solution that works for me because for some reason Robert's wasnt adding the nofollow attribute to the link. function add_rel_nofollow( $text ) { // This is a pre save filter, so text is already escaped. $text = ...


1

This will display them before the DISQUS comment form but not the count add_filter( 'comments_template', function( $pings_before_dsq_comments) { if( !function_exists( 'dsq_is_installed' ) || !dsq_is_installed() ) return $pings_before_dsq_comments; wp_list_comments( array( 'style' => 'ul', 'type' => 'pings' )); ...


1

You should be using home_url() ( or something similar ) in your links for theme files when linking to pages. This will allow the domain to change and not affect your hardcoded links - assuming the ID's are the same of course. <a href="<?php echo home_url();?>/?page_id=634">Link</a> Good luck!


1

Or, you can place this code in your active theme's functions.php: <?php // First, backup the default $postdata $backup = $post; // Now, override the default $tags = wp_get_post_tags($post->ID); // Now, open the if ( $tags ) statement if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = ...


1

If you want to display a single custom field (post meta) then you can use: get_post_meta(); It has three arguments. The ID of the post The name of the post meta field (country_flag) Whether or not the value returned is a single string (in your case it will be); So the usage might be something like this: $country_flag = get_post_meta( $post->ID, ...


1

Data in the WP database is serialized. If you just do a search and replace you'll break your site. You need to reserialize your data as you change it. There are scripts and services that allow you to do a proper Search and Replace. My tool of choice is this one, and it works perfectly. There are also a couple plugins that work (like velvet blues), and I ...


1

@Amirreza Nasiri - Yes that is possible. I have used following plugin to import large size files into WordPress Media library. Please take a look at this: https://wordpress.org/plugins/add-from-server/ I have no affiliation with plugin. I had used it for one of my client project and just found it as suitable suggestion for this question :)


1

To show all categories on a page, you will have to create a new page template. <?php /** * Template Name: Categories Page **/ get_header(); ?> <!-- content --> <div id="content"> <ul class="category-list"> <?php wp_list_categories( 'title_li=' ); ?> </ul> </div> ...


1

I was able to solve this by adding the WP Edit plugin to my site. It has an Advanced Link button, that allows me (or an editor) to manually type in a classname.


1

As your links are generated by get_archives_link(), this is the place where you have to look. Doing so, by inspecting the source , you will notice that get_archives_link() - itself - doesn't give you the possibility to add a CSS class to make the highlighting happen. There is of course the filter hook get_archives_link - or see the source - which could be ...


1

The other question is completely wrong and should not be used previous_post() and next_post() is both depreciated functions and should not be used anymore Never replace WP_Query with query_posts to solve a problem. This actually creates more. Also, query_posts should never be used showposts is also depreciated in favor of posts_per_page To make ...


1

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


1

The the easiest way to create shortlink is by using Jetpack Plugin developed by Automatic guys. This plugin comes with a lot of modules one of them is wp.me shortlink, which will give you the ability to create shortlink for any page/post/custom post in your site. it will be like http://wp.me/QhtyJu, but if you want to use any other shortlink service ...


1

I found the solution to my problem: wp_delete_post(url_to_postid("url"));


1

<?php // Display Custom Field Value echo "<ul>"; echo "<li>License Type: ".get_post_meta( $post->ID, 'License Type', true )."</li>"; echo '<li><a href="' . get_post_meta( $post->ID, 'Download Comp', true ) . '">Download Comp</a></li>'; echo "</ul>"; ?>


1

I believe you are using wordpress on your website...To add read more text u just need to use the wordpress visual editor. In this the 12 no. button is used to add read more text...Use this to add read more, there may be possibility that while adding code you are making some error..


1

This is mostly a PHP question and it is related to WooCommerce. Either of which conditions makes it dangerously close to off-topic. However, I am going to give the benefit of the doubt and assume that the problem is due to a misunderstanding of the WordPress function wp_get_post_terms(). ;) wp_get_post_terms() returns all of the terms as an array of term ...


1

WordPress has the function edit_post_link() to Displays a link to edit the current post, if a user is logged in and allowed to edit the post.



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