I am not sure what title to give to this topic, so i apologize.
I am having WP blog running customized theme, and i installed Wordpress Popular Post Plugin.
It works as it should, but just after the link, it displays weird character that shouldnt be there ":".
It looks like this:
Post Title Link
:
<span class="wpp-excerpt">WThis is post excrpt bla bla</span>
I really dont have any idea why it is showing there.If anybody have any suggestion/advice, i would be very grateful.
This is the link, Top Section in the right sidebar
The answer you're looking for is in row 1140 of the plugin file.
$excerpt = ": <span class=\"wpp-excerpt\">" . $excerpt . "</span>";
Just remove the colon and you're done.
Related
I have a wordpress website which is in both english and french, meaning that for every english page, there's its french counterpart with the same content. Until now, when I wanted to add something to it like a slideshow, I'd do two of them and add them on their respective pages but I have a problem with galleries and solo images as their caption and title are used directly in those cases. I don't want to upload each image twice with different properties so I wanted to add a function in php that switches the language for me.
My idea was to put tags in the images caption to have something like that :
[EN] EN description
[FR] FR description
And have the function get this string and work it to remove what has to be removed for the current page. My problem is that I don't really know php and even less the WordPress api of which I struggle to understand how it works, what I get when I call a function or even what it's talking about in the functions description.
So my question is this: Is there a way to get all the images of a page and edit their properties ? If yes, how ?
I tried to search for clues on the internet and found this code that I wanted to use as a base but I'm not sure it's working:
$PageID = get_the_ID();
$Post = get_post( $PageID );
$Content = $Post->post_content;
$Regex = '/src="([^"]*)"/';
preg_match_all( $Regex, $Content, $Matches );
foreach( $Matches as $Image ):
echo '<img src="'.$Image.'" alt="'.$Post->post_title.'" title="'.$Post->post_title.'">';
endforeach;
Maybe I'm missing something but when I try to print $Matches or $Image in the console, all I get is "Array" and it gives me a broken image with my page title on its side if I try to run it.
Thank you for your time.
If you want to change HTML markup for each image (ex. add custom attributes to each <img>), maybe this is a good thread: Change html structure of all img tags in Wordpress # wordpress.stackexchange.com
If you want to change how WP outputs the caption for an image, which is inserted based on a shortcode in the editor, then this WP codex page should help: Plugin API/Filter Reference/img caption shortcode # codex.wordpress.org
There is an example in the second link. You should be able to get the image caption in a variable (see $attr['caption']) - and then you should filter it (ex. remove the [EN] description). But you need to figure how to access the language of the page in that function.
I need to to add a short code into a short code in WordPress.
[mycred_link href="http://www.mycred.me"]View portfolio[/mycred_link]
This short code above is a short code from myCred plugin, it gives users points when they click on the link inside the short code.
What I need is:
To show a Facebook share link, inside the short code using. I already have a short code that generates a Facebook share link.
I need something like this:
[mycred_link href="[facebook_share_link]"]View portfolio[/mycred_link]
To give users points when they share my posts on Facebook. I tried it but it didn't work.
I also tried this code below, it Gives point to users and opens facebook.
But facebook says that URL is invalid.
<?php echo do_shortcode( "[mycred_link href='http://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode(get_permalink()); ?>']View portfolio[/mycred_link]"); ?>
If I put double quote after the href the wordpress footer will disappear completely, am running the second code on my footer.php
The problem is inside the code of myCred plugin. As you can see from the source code of the plugin wp-content/plugins/mycred/includes/shortcodes/mycred_link.php what you pass inside the href attribute doesn't get parsed with do_shortcode therefore you will not be able to insert.
As you can see from this answer:Shortcodes inside a shortcode - wordpress wordpress shortcodes doesn't stack automatically.
Luckily for you the function end with:
return apply_filters( 'mycred_link', '<a ' . implode( ' ', $attr ) . '>' . do_shortcode( $link_title ) . '</a>', $atts, $link_title );
So w/o touching the plugin source code you can use the filter and then do something with the href. My guess is something like this (not tested)
Inside your function.php in your theme folder insert something like this:
add_filter('mycred_link','edit_mycred_link',10,3 );
function edit_mycred_link($link_html, $atts, $link_title){
return str_replace('__edit_mycred_link__',do_shortcode('[facebook_share_link]'),$link_html);
}
And then inside your template file / post content
[mycred_link href="__edit_mycred_link__"]View portfolio[/mycred_link]
That should work
I finally solved the problem. I asked the question on wordpress forum and a moderator gave it to me.
<?php
echo do_shortcode( '[mycred_link href="http://www.facebook.com/sharer/sharer.php?u=' . urlencode( get_permalink()) . '"]View portfolio[/mycred_link]');
?>
I'm trying to add <br /> code to widget titles in Wordpress, as most of my widget's titles are on two lines, and I would like to format the text so it makes more sense to the reader.
I've tried a few different suggested solutions, including adding various code to the Functions file:
add_filter('widget_title', 'change_widget_title', 10, 3);
function change_widget_title($title, $instance, $wid){
return $title = str_replace('Widget Title', '<span style="color: red">Custom</span>', $title);
}
That didn't work for me unfortunately.
Nor did #4 on this page:
http://www.rvamedia.com/wordpress/customize-wordpress-widget-title
I don't even need the title to link to anything, I just want to put in a <br /> so it'll show properly on two lines.
Any help would be greatly appreciated.
I know its a little late for the answer but may be it will help others
Its very simple, You can get help from shortcode by
add_filter('widget_title', 'do_shortcode');
function line_break() {
return '<br />';
}
add_shortcode('br', 'line_break');
Put this in your functions.php file at the end than use <br/> as shortcode i.e. br
I figured out an alternative to this issue.
Instead of putting a br in the widget title, I put the first line of the title as the title, and then inserted a div with the same background color and text color at the very top of the text widget that had the second line.
You can then style this div to have the same qualities as the widget title e.g. no underline, no text transform, etc. to make it look the exact same as the widget title.
I want to change the wordpress blog widget title such as Archives, Recent Post, Recent Comments.
I search in many ways. I know it is execute in the file of default-widgets.php. The lines is
$title = apply_filters('widget_title',
empty($instance['title']) ? __('Recent
Posts') : $instance['title'],
$instance, $this->id_base);
I made the changes in that but it is not reflect anything. So please help me.
Where and How should be changes this ?
I really don't think hacking around in default-widgets.php is a good idea, unless you really know what you are doing. Changing default-widgets.php means that you have to account for upgrading Wordpress.
Instead, I would suggest creating a new widget to do what you would like it to do and not play around with the Wordpress core.
Here's a decent tutorial on creating this: http://www.lonewolfdesigns.co.uk/create-wordpress-widgets/
I just found this post, and it's exactly what I needed -- I think it might work for you too. It shows you how to create a filter for the widget_title callback to modify the title however you want to.
http://coderseye.com/2010/modifying-widget-titles-in-wordpress.html
I have same problem too, after reading you tips i have find it out, just edit the 'change here' , problem would be solved.
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'change here' );
You can change the title using a filter hook widget_title
function new_widget_title($title) {
if ($title == 'Recent Posts') $title = "Greatest posts";
return $title;
}
add_filter ( 'widget_title' , 'new_widget_title', 10, 3);
for WordPress 2.8
Just open the file named:default-widgets.php which can be located inside the wp-includes directory and delete/modify there and upload to ur server, as simple as that. *This was found before in the widgets.php in previous versions.*Also to remove the search for title and replace it u can just delete the text in the php file.This is the line for changing title -
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title']);
}
Keep in mind though that if and when you upgrade to the next version of WP you will also update the /wp-includes directory thus overwriting the defaults-widgets.php file, so make a backup copy.
Also look here to Disable default WordPress widgets like archives,meta-links,recent-posts etc..
For adding widgets like archives, recent posts:
On dashboard, go to Appearances->Widgets.
On left hand side of that window, you will see archives, just move the cursor on it, uou will see a hand symbol on it. Then just drag and place it on right side of that window, below
the main sidebar. Then, give the title as you want and click save and so on, the same for recent posts.
Then, on left top of the blog or website, click your website or blog name to see your archives, recent posts as sidebar.
wordpress , plugins : hi , I want to create website by wordpress but I want to make speacial plugins .. and I made it but there are problem .. _
I have a website and I using it with wiki for contries in the world ..
I want from the plugins 'when the visitor open the page for example 'United State' , I want from the plugins to search about all of world in this page like cities ' New York , .... ' and replace it by like for city's page for example = New York ..
I don't know how make it ..
I tried few times but I fail >_< ..
<?php
/*
Plugin Name: ReplaceMent
*/
$wiki_contry = array ("Japan"=>"<a href='?japan.php'> Japan <a/>","United State"=>"<a href='?usa.php'> United State <a/>");
function replace($text){
foreach ($wiki_contry as $ky => $vl){
$text = str_replace(ِ"$ky","$vl", $text);
return $text;
}
}
add_filter('the_content','replace');
?>
other world , I want my site like wikipidia but using wordpress and plugins ^_^..
thank you very much
I hate to be frank but your English is terrible. I can't clearly understand what you're doing or why you're trying to do it.
Why would you want your site to be like Wikipedia utilizing Wordpress and its plugins when you can just use MediaWiki for free?
Replying to quite an old post,
but .. the answer seems to be kind of missing,
so I am giving it a shot, to provide an answer.
Perhaps adding this in your function-body will help ?
global $wiki_contry;
And perhaps a less intense way to do it would be something along the lines of the content described in this article https://themefuse.com/wordpress-tutorial-how-to-link-keywords-to-urls-automatically/ . So, essentially a function that replaces the text content when it is saved, using WordPress-hook 'content_save_pre', to execute the replace function and save that text to the database.
add_filter('content_save_pre','replace_keywords_fn');
I would also like to suggest to you the idea of using tags for the countries and regions, so you can point to the overview page for that tag.