- This topic has 10 replies, 3 voices, and was last updated 4 years, 4 months ago by
David.
-
AuthorPosts
-
December 27, 2018 at 1:49 am #766417
Fernando
Hi,
I want to put “breadcrumbs” in my blog, but not the typical ones that Yoast SEO puts, but similar to the ones in David Ayala’s Blog (https://www.soywebmaster.com/david-ayala/demasiados-dominios-para-mi-body-cual-cojones-elijo/).There you can see how the categories are linked and even the post itself is linked to its title.
I would like that the code or solution you give me can be inserted as a Hook or similar, so that when updating the theme is not deleted.
I would also like to comment that I have been given a code to make these breadcrumbs, but it does not work, as I do not take the category. I put the code here for you to review:
December 27, 2018 at 9:42 am #766831Tom
Lead DeveloperLead DeveloperHi there,
It looks like that site is using Yoast to output their breadcrumbs. Have you tried Yoast to output them with no luck?
December 28, 2018 at 3:26 am #767454Fernando
Hi Tom,
If I’ve tried Yoast’s bread crumbs. The “problem” with Yoast bread crumbs is that it doesn’t link to the current page or category. For example, if it is within a subcategory, it only links to the category it belongs to and to the home page, but I want it to link to the subcategory as well.
And also if for example we are in a post that is within a subcategory, I want to link both the title of the current post, as the subcategory, as the category and as the home.This is an essential and necessary technique for SEO.
How can I do it?
December 28, 2018 at 5:15 am #767519Fernando
Hi,
I already got what I wanted, but I had to use the plugin “Breadcrumbs NavXT” and insert a Hook code in “Elements”.
The problem now is that to insert this hook code, I had to deactivate the “edit files” box in my security plugin (so that it can run php).
Is there any way to run php on a single hook and have the “edit files” checkbox enabled?December 28, 2018 at 5:37 am #767528David
StaffCustomer SupportHi there,
hmmm.. probably easier to add the function to your child theme functions file using a snippet like so:
add_action( 'your_hook_name','example_function_name' ); function example_function_name() { ?> Insert your hook contents in here. <?php }
Guide to Hook locations / names:
December 29, 2018 at 1:38 am #768295Fernando
Thank you very much David! It’s a good idea, but I can’t do it.
It shows me the following error, and I don’t know if I did it right:
syntax error, unexpected ‘bcn_display’ (T_STRING), expecting ‘,’ or ‘)’.This is the php code of the hook I want to put:
https://pastebin.com/41Uc3aXDAnd this is the code that I have made following your indications, but it has generated the error that I have mentioned before. Let’s see if you can help me make the code work.
//Para implementar las migas de pan en las categorias
add_action( ‘generate_after_archive_title’,’breadcrumbs_navxt’ );
function breadcrumbs_navxt() { ?><?php if(function_exists(‘bcn_display’))
{
if(!is_home() && !is_front_page()){bcn_display();}
}?><br>
<?php }Thank you very much!
December 29, 2018 at 5:24 am #768397David
StaffCustomer SupportTry this:
add_action( 'generate_after_archive_title','breadcrumbs_navxt' ); function breadcrumbs_navxt() { ?> <div class="breadcrumbs" typeof="BreadcrumbList" vocab="http://schema.org/"> <?php if(function_exists('bcn_display')) { if(!is_home() && !is_front_page()){bcn_display();} }?> </div> <br> <?php }
December 31, 2018 at 3:32 am #769701Fernando
Hi,
Not found. This error appears:
syntax error, unexpected end of fileAnd what I’ve done is put in the end “the end of code php” and it hasn’t given me error. But I only got “http://schema.org/”>” in the breadcrumbs.
So what I’ve done is put the code “https://pastebin.com/41Uc3aXD” instead of “http://schema.org/”>” and then I look good, but only in the categories that have been assigned a blog entry. In those that don’t have blog entries, bread crumbs don’t appear…
Any ideas?
December 31, 2018 at 8:35 am #769987Tom
Lead DeveloperLead DeveloperWhat happens if you add Davids code using the Code Snippets plugin?: https://docs.generatepress.com/article/adding-php/
January 17, 2019 at 4:26 am #784460Fernando
Hi Tom,
It doesn’t allow me to enter David’s code into the Code Snippets plugin.Can you test the code and pass me the exact code for the plugin?
January 17, 2019 at 8:30 am #784771David
StaffCustomer SupportHi there,
i tried the code in Code Snippets and no errors reported. But i don’t have the BCN function, so maybe the issue is related to that.
-
AuthorPosts
- You must be logged in to reply to this topic.