Tag Info

Hot answers tagged

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

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

Well if your code is working properly and the only problem is that it displays when no one is logged in then try the code below. Because right now you are saying "Hey WP just echo out this" - so it does it. You need to change it to: "Hey WP if the user is logged in show the link to his page and if not show the login link" like that: <?php if ( ...


2

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


2

Add a rewrite rule and extra query vars to handle incoming requests, direct the rewrite rule to a single page post type, create a custom page template for that page, then do whatever querying you need using the query vars set by your rewrite rule.


2

Create a page with the name links. Pages >> Add New into your wordpress panel. Just name it links and publish. See below. Now go to your theme folder wp-content\themes\YOUR_ACTIVE_THEME_FOLDER and create a page page-links.php. And paste this code in page-links.php <?php $the_query = new WP_Query(array('post_type' => 'post')); ...


2

If you are talking about menus and your theme uses the Menu API, then upload the PDF to a publicly accessible server-- doesn't have to to be the one your site uses-- then go to Appearance -> Menus, Navigate to a menu, or create one find the "Links" dialogue, input the URL and the link text Save


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

Please refer to this link http://codex.wordpress.org/Changing_The_Site_URL It is possible to set the site URL manually in the wp-config.php file. Add these two lines to your wp-config.php, where "example.com" is the correct location of your site. define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');


2

It's a valid theory and under some circumstances such micro-optimization might make a difference (making content fit into single packet rather than be split into two). However you misinterpret the size information. 8.5KB is gzip-compressed version of your page. Since repeats of same string are highly compressible, your optimization won't reduce this by 5KB. ...


2

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


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


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


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

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

https://wordpress.org/support/view/plugin-reviews/google-sitemap-generator https://wordpress.org/plugins/sitetree/ You may use this plugins else you can even create a page with all pdf link to download it.


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

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

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

The solution for this is, in my opinion, divided into two steps. The first step is to set the variable, which defines the affiliate, that sends you the visitor. The second step is to display an appropriate logo based on the value of the first variable. The solution for the first step would probably look somewhat like this: if( isset($_GET['affiliate']) ...


1

You can use the count property of the taxonomy term and if it is > 1, then show the term linked to archive. // inside loop, get the terms of a custom taxonomy for the current post $terms = get_the_terms( get_the_ID(), 'your_custom_taxonomy' ); // cycle the terms and display the name, linked to archive if term count is > 1 foreach ( $terms as $term ) ...


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

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


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

get_post_meta() only returns the output, but does not print it. You have to use either echo or the_meta() to print the actual output. href="<?php echo get_post_meta(get_the_id(), 'ramco-videos-link', true);



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