- This topic has 15 replies, 4 voices, and was last updated 7 months, 4 weeks ago by
David.
-
AuthorPosts
-
May 27, 2020 at 11:09 am #1303897
William
Hello! Need help with 2 things
1. I wanted to use a static page as category archive so I used the PHP code mentioned on here
I used a snippet plugin to add it and it does take me to the static page. However, the problem is when I click on the post titles on the static page, instead of taking me to the post, it brings me back to the static page. Same thing happens on the homepage. The post design on my homepage includes category above title and when I turn the function on using the snippet plugin, everytime when I click the title (not category) of the post on the homepage it brings me to the static category page I created.
2. I try to make the author not clickable by using another PHP mnetioned here . I used the last function and it’s still clickable.
By the way I disabled both PHP snippets because my site is live
Thank You
May 27, 2020 at 4:33 pm #1304211Tom
Lead DeveloperLead DeveloperHi there,
1. Not sure what would cause this, unfortunately. I assume it has to do with your permalinks. What are they set to?
2. That filter is for GeneratePress. This might help: https://wpshowposts.com/support/topic/remove-links-from-dateauthor/#post-3452
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 27, 2020 at 6:06 pm #1304271William
Hi Tom,
1. My permalink structure is site.com/category/postname
When I turn the snippet on for the PHP if I click on the post title, the URL is correct (site.com/category/postname) but the page it shows is the static category page not the post.
2. How do I remove the author link in the post also? The one inside the feature image.
Thank You!
May 28, 2020 at 6:20 am #1304902David
StaffCustomer SupportHi there,
1. not sure about this – template redirects are painful especially when cat-slugs are in the URL.
Whats the purpose of using static pages for Category Archives ? They’re may be an alternative way.2. In Appearance > Elements – edit the Header Element for the single post and remove the
{{post_author}}
template tagDocumentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 28, 2020 at 9:22 am #1305289William
Hi David,
1. So what I want to achieve is to make my category archive pages to look like the category static pages I created. Right now if you click on the category names those archive pages have different layout compared to the pages I created in the navigation bar. Once users click on the category, I want it to bring them to the same pages in the navigation bar.
2. I mean author link, not the text. I want to make author names non clickable
Thank You!
May 28, 2020 at 2:07 pm #1305593Tom
Lead DeveloperLead Developer1. Ah, I’ve seen this before, but I don’t believe we found a solution. That specific function just doesn’t seem to work with that permalink structure. It might be worth asking over on https://wordpress.stackexchange.com/.
2. Try this:
add_filter( 'generate_page_hero_post_author', function() { return sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-name" itemprop="name">%s</span</span>', esc_html( get_the_author_meta( 'display_name', $author_id ) ) ); } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 28, 2020 at 9:03 pm #1305829William
Hi Tom,
Thank You, was able to get rid of the author link. As for the category archive, since I can’t link category archives to a static page is there a way to edit/customize the category archives to at least look like the static pages I created in the navigation bar?
Thanks
May 29, 2020 at 2:01 am #1306015David
StaffCustomer SupportCan you add these two PHP Snippets to your site:
add_filter( 'generate_header_entry_meta_items', function( $items ) { if ( is_archive() ) { $items = array( 'categories', ); } return $items; } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { if ( is_archive() ) { $items = array( 'author', ); } return $items; } );
This should move the Category above the title and place the author below.
Once done let me know so i can take a look at the CSS requiredDocumentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 29, 2020 at 10:34 am #1306793William
Hi David,
Just added the snippet. Also, any idea how to get rid of “by” in front of the author’s names? Thank You!
May 29, 2020 at 1:04 pm #1306929Leo
StaffCustomer SupportCan you try this:
add_filter( 'generate_inside_post_meta_item_output', function( $output, $item ) { if ( 'author' === $item ) { return ''; } return $output; }, 50, 2 );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 29, 2020 at 8:52 pm #1307177William
Hi Leo, Thank You! Was able to get rid of “by”. Now just waiting on the CSS. Thanks!
May 30, 2020 at 4:50 am #1307480David
StaffCustomer SupportTry adding this CSS:
.generate-columns-container article .inside-article { padding: 30px; box-shadow:1px 3px 5px 1px rgba(0, 0, 0, .09); text-align: center; } .generate-columns-container article .inside-article .post-image { margin: -30px -30px -30px -30px; } .generate-columns-container article .inside-article .post-image img { width: 100%; } .generate-columns-container .entry-header .cat-links a { display: inline-block; font-size: .75em; text-transform: uppercase; padding: .25em; background-color: #f2970e; color: #fff; min-width:100px; margin-bottom: 2em; } @media (max-width: 768px) { .generate-columns-container article { margin-left: 20px; margin-right: 20px; } }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 30, 2020 at 10:05 pm #1308273William
Hi David, I have some technical difficulties with the “code snippet” plugin after adding a php code with an error. I managed to contact my hosting company to delete the plugin, but once I reinstall, I get the error again. From what I read here: https://docs.generatepress.com/article/adding-php/ it says im able to delete the code through cpanel. Any idea where I can navigate to find the code?
Once i fix this issue I can then test out the CSS you provided since it requires php snippets. Thank You!
May 31, 2020 at 6:10 am #1308559David
StaffCustomer SupportSee here to enable Safe Mode in Code Snippets – this will allow you to access your site and delete the bad snippet:
https://wordpress.org/support/topic/help-i-just-activated-a-snippet-and-my-site-broke/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 31, 2020 at 12:15 pm #1309046William
Hi David, Thanks! I’ll give it a shot.
-
AuthorPosts
- You must be logged in to reply to this topic.