Seo yoast plugin, breadcrumbs - wordpress

This is question on the seo yoast wordporess plugin.
I have a friend who doesn't know that much about code/wordpress/etc, they have an ecommerce site built using magento and a blog using wordpress which is styled to match the main site and they use yoast seo plugin for seo etc. They have asked me to try an get the breadcrumbs working for them in a different way to what i know, from what i can see they want to add a prefix to the breadcrumbs 'home' which links to main site then renaming the blog from home to blog, for example home(main site) > blog(blog) > post.
Now i did just that in the plugin settings but they said that the schema markup wouldn't be complete and said there’s a filter hook called ‘wpseo_breadcrumb_links’ which gives access to the array of URLs and anchor text used to build the breadcrumbs, now i cant find anything on google that explains this or how to start writing it, i do know that it needs to go in the functions file.
Would it be possible to get some help on this.
Thanks in advance and very much appreciated.
Justin

I'm not sure what Schema.org markup has to do with breadcrumbs! :) Schema is used on post/page level. So, they are either oversmarting themselves or I got you wrong.

I think this sample code may be helpful:
add_filter( 'wpseo_breadcrumb_output', 'custom_wpseo_breadcrumb_output' );
function custom_wpseo_breadcrumb_output( $output ){
if( is_product() ){
$from = '<span typeof="v:Breadcrumb">Products</span> »';
$to = '';
$output = str_replace( $from, $to, $output );
}
return $output;
}
It looks like wpseo_breadcrumb_output gives you access to the entire output instead of just the link portion. Please see this page for more details: http://wpquestions.com/question/showChrono/id/8603

Related

How to Add "itemReviewed" in WP-postratings plugin

I want to set up the markup of Reviews on the site that would be in the snippet search engine displayed stars and the author of the review.
CMS site: WordPress 5.3 - Astra theme
I use the plugin: WP-Postrating (https://wordpress.org/plugins/wp-postratings/)
1.changed the type of markup in function.php using the filter as described in the plugin instructions:
add_filter( 'wp_postratings_schema_itemtype', 'wp_postratings_schema_itemtype' );
function wp_postratings_schema_itemtype( $itemtype ) {
return 'itemscope itemtype';
}
Markup is now defined as Review link
But because of the error: It is necessary to specify the value for the itemReviewed field.
Stars and the author are not displayed in the snippet of the search system.
Please give us a hint. What code should I add to function.php to add this field? And what would you like to see in this field, for example, the title of an article or manually fill in itemReviewed. Perhaps you need to add some special field to the article editor.
I would be very grateful. The employer wants to do this, I am a novice developer at https://improvecraft.com/
It's an old question and you probably figured out how to add this code. If someone still needs it, this code should work (and you can change also itemtype):
add_filter( 'wp_postratings_schema_itemtype','wp_postratings_schema_itemtype');
function wp_postratings_schema_itemtype($itemtype) {
global $post;
$title = get_the_title($post->ID);
return 'itemscope itemReviewed="' . $title . '" itemtype="http://schema.org/LocalBusiness"';
}

Edit <title> in bbPress homepage

I want to do something like that: <title>Custom text...</title>
On the bbPress homepage. I've spent hours looking for the answer and I can't find it...
I know that it's possible to create page and add shortcodes like here: https://codex.bbpress.org/features/shortcodes/
But in this case it doesn't work if my root slug for bbPress is the same like the page. If slug is different - I will have two homepages :/
Do anybody had similar issue?
you can use this hook to execute your custom code top of the bbPress homepage.
'bbp_template_before_forums_index'
example:
add_action( 'bbp_template_before_forums_index', 'your_callback_function' );
function your_callback_function(){
$output_html = '';
$output_html .= "<title>Custom text...</title>";
echo $output_html;
}
use this code in your functions.php file, i hope it'll help you.

Wordpress: How to pass additional Content to the blog-preview page?

For each blog-post on my wordpress-blog I'd like to have Teaxtarea where i can pass additional content for that post.
In my case that would be an unordered list which contains a quick overview of the content.
That additional content should be displayed in the preview of the post on the blog-preview-page.
My problem:
I am actually not sure on how to best add this additional content and then pass it to the preview.
Do I use wordpress' custom fields for something like this?
I'm gratefull for a push in the right direction.
Thank you,
Nils
If I understand you right, I'd take a look at "custom meta boxes" functionality - it allows you to add any type of additional input into your blog post admin area, and than display its content on front-end however you like.
There's a nice tutorial series on that topic, with example code snippets:
http://wp.tutsplus.com/series/reusable-custom-meta-boxes/
And if you'd like to display the textarea content only in preview mode, you can use appropriate conditional tag in you template file:
http://codex.wordpress.org/Conditional_Tags#A_Preview
The conditional tag is_preview returns true when a single post is viewed in Draft mode. The following will append post meta to the content when a post is being previewed:
function so16799607_preview( $content )
{
if ( ! is_preview() )
return $content;
return $content . get_post_meta( get_the_ID(), 'my_post_meta', true );
}
add_filter( 'the_content', 'so16799607_preview', 10, 1 );
You should check out Advanced Custom Fields. That's a really stable plugin that lets you create custom meta boxes in posts, pages and custom post types. That plugin does exactly what your question states. Need al little PHP to get stuff from your database, but that is as easy as:
<?php the_field(field_name);?>
And the documentation is pretty good. And if you don't like a plugin, it exports the PHP as well.
Anther tool that does the same is Pods Framework. Both powerfull extensions to any WP install in my opinion.
Hope this helps.

Wordpress adding thumbnails to category

How to take on a problem in WordPress admin editing.
I'd like to edit an edit-category admin panel to add a featured image to it (just like in posts), but I'm a bit indecisive since a lot of people use a custom field with static path to a photo, but I'm wondering is there a way to do it better(enable some wp hook and such).
Can someone point me in the right direction?
Thanks for the plugin it seems good, but i have one additional problem. It seems i have a lack of knowledge on how to query an object [category] so i can apply filters, hope im making some sense. This is done on my home.php. all dumps are null
<?php get_header();
$listcat = get_categories('hide_empty=0');
foreach($listcat as $x){
$img = apply_filters( 'taxonomy-images-queried-term-image', '');
var_dump($img);
}
get_footer(); ?>
The same code works with no problems if i stick it in category.php. Any ideas? :)
i've used several times the plugin "Taxonomy Images". it works with multi-language wp installs too.
link with instruction: http://wordpress.mfields.org/plugins/taxonomy-images/

Displaying code snippets in WordPress

Ok, not technically a programming question but I want a plugin for my WordPress blog that displays code snippets.
Can anyone here recommend a good one? Also, do you guys know which one Jeff uses on codinghorror. That one looks really good.
Thanks.
wordpress.com claims to use Alex Gorbatchev’s syntaxhighlighter Google Code project.
I guess you might be interested in run-this - there is a wordpress plugin to allow your readers to run your snippets in the browser.
For WP-Snippets, I use Prettify.
You should probably use a plugin for escaping characters to be able to display code without having to do it yourself, or your code wont be displayed. Or just put this in functions.php in your theme folder to do this automatically:
function bbcode( $attr, $content = null ) {
$content = clean_pre($content); // Clean pre-tags
return '<pre"><code>' .
str_replace('<', '<', $content) . // Escape < chars
'</code></pre>';
}
add_shortcode('code', 'bbcode');
And then wrap your code with [code]<?php echo 'hello world!'; ?>[/code]
Source: Code in posts

Resources