how to change a comment structure in wordpress - wordpress

i am working on my wordpress theme, and comment time/date are showing up in one continuous timestamp tag:
<time datetime="2015-12-21T19:09:49+00:00"> december 21st, 2015 on 19:09 </time>
i would like to have the time of day be wrapped in a span tag, so i can style it with css. the comment.php file on my theme uses this to list the comments, and there's no way to edit the timestamp here:
<ol class="comment-list">
<?php
wp_list_comments( array(
'style' => 'ol',
'format' => 'html5',
'short_ping' => true,
) );
?>
</ol>
i tried looking at my theme's functions.php, as well as wordpress' include files: comment.php and comment-template.php. none of them deal with the actual tag structure of the time-stamp, so there was nothing there for me to play with.
does anyone have any idea how i can do this? obviously, i'd rather do it in my theme's functions.php than alter the wp inc stuff..
thanks!

Usually the comment date stamp is defined by :
.comment-metadata a, .pingback .comment-edit-link
Search for something like this in style.css and you can style them.

Related

template management with wordpress (underscore boilerplate)

I am using underscore to develop a wordpress theme.
I have a custom post type name project, thus I have, for instance, this url: http://a.site.local/projects/a-beauty/.
I have in my template-parts/ directory the file content-projects.
$ cat template-parts/content-projects.php
<h1>Project</h1>
When I browse http://a.site.local/projects/a-beauty/, I have my title but also the sidebar and the footer (even if they do not appear in my content-project.php nor in index.php).
Where are those widgets coming from / loaded ?
Add conditions to the header, footer and sidebar.
For whole custom post archive:
<?php if( !is_post_type_archive( 'project' ) ) : ?>
// wrap the code you don't want to show on that archive
<?php endif; ?>
For custom post only:
<?php if( !is_singular( 'project' ) ) : ?>
// wrap the code you don't want to show on the post
<?php endif; ?>
If you want to put the code you WANT to show, remove the '!' before condition.
P.S.
You can put the whole content in a condition, but keep the
</div><!-- #page -->
<?php wp_footer(); ?>
</body>
</html>
otherwise the page will break :)
Please share some more code from your project so we can easy to understand the real problem.

Prevent remove blocks from template

First of all i'm using acf to create gutenberg blocks (i think it's important to say about it).
I made custom post type for my restaurant menu, where i want to force exactly the same layout for each
posts.
I made background block to can adding blocks inside there.
<div class="background">
<div class="background-color" style="background-color: <?php echo $background ?>"></div>
<InnerBlocks />
</div>
To get similar layout to each posts i set template parametr in my cpt
'template_lock' => 'all',
'template' => [
['acf/background', ['className' => 'meal_description', 'data' => ['admin_section_name' => 'Meal description']], [
['core/paragraph', ['align' => 'center', 'placeholder' => __('Your block there', 'restaurant')]],
]],
];
Unfortunately when i set template_lock to all i cant add block in my 'inner_blocks" called background.
I'm looking for solution in which admin could add some block only in predefined blocks.
Have you tried adding templateLock="false" to the InnerBlocks element?
E.g. <InnerBlocks templateLock="false"/>
templateLock is passed down to child elements, so setting the value on the InnerBlocks should overwrite the parent value.
https://github.com/WordPress/gutenberg/tree/master/packages/block-editor/src/components/inner-blocks#templatelock
If locking is not set in an InnerBlocks area: the locking of the
parent InnerBlocks area is used.

In Wordpress get category ID within a blog roll

I'm not a fan of the default blog roll for a theme that I'm using, so I'm deconstructing it, so far I was able to pull into the blog roll template:
Author: get_the_author_link()
Date with formatting: the_time('F jS, Y');
What I'm having trouble with is pulling in the categor(eis) for each post. I've tried:
get_the_category(); // with or witout the get_the_ID()
But All I get back the array object. I then tried traversing to no avail. What am I doing wrong? Again, this is not an individual post, but a blog roll.
You're looking for get_the_category_list().
This function takes three parameters - separator, parents and post id (in that order).
So, you'll want to do something like this:
<?php echo get_the_category_list(', ', '', get_the_ID()); ?>
This will create a an unordered (ul) list with commas in between the category names. You will most likely need to use some CSS to make the li items float or set them to inline block. Something like this:
<ul>
<li>Cat 1, </li>
<li>Cat 2, </li>
<li>Cat 3</li>
<ul>
You can also use get_the_term_list(). This has a little more flexibility in the final output of the category terms.
get_the_term_list() accepts five parameters: post id, taxonomy, before, separator, after.
For your use you would do this:
<?php echo get_the_term_list( get_the_ID(), 'category', '<span>', ', ', '</span>' ); ?>
This will output something like this:
<span>Cat 1, Cat 2, Cat 3</span>
You can change the wrapper (<span>), I just used that as an example.
Here is documentation on both functions from the Codex:
https://codex.wordpress.org/Function_Reference/get_the_category_list
https://codex.wordpress.org/Function_Reference/get_the_term_list

How to add css class to approved comment

In my theme, I use wp_list_comments() to display comments, I want to add a css class to new approved comment, I have tried to find a filter or something like this but couldn't find anything. Does anyone has a solution to do it, I don't want to edit in wp-includes/comment-template.php. Thank a lot!
You Will Find Code Into wp-includes/comment-template.php
Into Line 1997
<div class="comment-content">
<?php comment_text(); ?>
</div><!-- .comment-content -->
Add Your Custom HTML Here
<?php
ob_start();
comment_form();
echo str_replace('class="comment-form"','class="comment-form your-custom-class"',ob_get_clean());
?>
Now the standard class comment-form will be replaced by itself plus the custom class.

Data/Content Architecture in WordPress 3.1

Update
I solved it in that way:
What you need:
Custom Post Type
Enabled Plugin "Posts 2 Posts" (see comments below)
Enabled Plugin "Allow numeric stubs"
You'll need the Plugin "Posts 2 Posts" to assign posts tp pages. "Allow numeric stubs" is a plugin that will allow you to have numeric slugs for pages. If try to add pages named to 2011 or 2012 you'll get Page-Slugs like 2011-2 or 2012-2 because it is not possible to have a page slug that is a number.
First you have to add some Pages. For Example 2011, Nominees and Actors. Now you arrange the Pages as childs to your needs.
2011
-Nominees
--Actors
Your Url will now look like http://example.com/2011/nominees/actors
Now you have to add a Custom Post Type which contains your nominees. Add some nominees to your Post Type (should work with Articles too).
Register a connection type in your functions.php
function my_connection_types() {
// Make sure the Posts 2 Posts plugin is active.
if ( !function_exists( 'p2p_register_connection_type' ) )
return;
p2p_register_connection_type( array(
'id' => 'posts_pages',
'from' => 'page',
'to' => 'nominees' // Your Post-Type
) );
}
add_action( 'init', 'my_connection_types', 100 );
Now go to your Actor-Page, look for a MetaBox named "Connected Nominees" and add your nominees.
Edit your page.php
<article class="single entry">
<header class="post post-header">
<h1><?php the_title(); ?></h1>
</header>
<section class="post post-content">
<?php the_content(); ?>
<?php
// Find connected pages
$connected = p2p_type( 'posts_pages' )->get_connected( get_queried_object_id() );
// Display connected pages
if ( $connected->have_posts() ) :
?>
<?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
<?php
// Prevent weirdness
wp_reset_postdata();
endif;
?>
</section>
</article>
Now you should be able to see you asigned Posts (nominees) on your Page Actors.
The solution is easy to understand for authors since they are working with default wordpress behaviors and the content connection process feels really native.
I'm looking for some data architecture best practices in WordPress 3.1.n
Here are the facts:
It is some kind of award
The Award has **n** different categories
People could be nominated
Each nominee could be asscociated with 1 category
Each category is grouped by year
Each category can contain up to 3 or 5 nominees
Categories/Terms(?)
2011
actor
special-effects
story
2012
actor
special-effects
story
For Example:
http://example.com/nominees/2011/actor/all-nominees-in-actor-cat-in-2011.html
http://example.com/nominees/2011/special-effects/all-nominees-in-special-effects-cat-in-2011.html
http://example.com/nominees/2012/special-effects/all-nominees-in-special-effects-cat-in-2012.html
Note: Custom Post-Types and Custom Taxonomies are fine but i can't get hirachical Taxonomy-Terms work.
Does anyone have some suggestions to solve this with WordPress?
You might consider creating an "Award" post type with categories being the types of awards... Best Actor, Special Effects, etc. Also you could tag each award post by what year it is. I like tagging the year vs a year as a category because it gives you the option to build and scale content by year as the site grows. However a category would work as well.
Then, perhaps create an Actor post type with each actors name, this would have the added benefit of being scaleable should you want to expand on actor profiles down the road. Then consider connecting them using something like the "Posts 2 Posts" plugin. Plugin here
This plugin is great for associating posts with other posts like a "review" post with a "product" post. You will essentially be doing the same thing except "review" would be substituted with "award" and "product" would be associated with "actor".

Resources