In file '/wp-includes/comment-template.php', in function comment_form() exist action - 'do_action('comment_form_before')'. Below this action written code
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3>
I want to replace all this code by my own code. How I can do it?
Related
Maybe it's duplicate but I don't know how it calls and cannot find. I need to load a php-file (template of my block) and set content into it.
For example, template file:
<?php include_once 'boot.inc' ?>
<div class="widget">
<div class="widget-title">I need to put title here</div>
<div class="widget-body">I need to put content here</div>
</div>
And php function to insert new block with this template:
function nm_new_block($title, $content) {};
Can I do it in php?
1° Solution: You need to change you code into:
<?php include_once 'boot.inc' ?>
<?php include_once 'template.php' ?>
<div class="widget">
<div class="widget-title"><?php echo $title; ?></div>
<div class="widget-body"><?php echo $content; ?></div>
</div>
In template.php file you must have something like this:
<?php
$title="My Title";
$content="My Content";
?>
And you don't need function for this cause variables are stored in template.php
2° Solution: You need to implement a function to retrieve variables from external source:
<?php include_once 'boot.inc' ?>
<?php include 'functions.php' ?>
<div class="widget">
<div class="widget-title"><?php echoTitle(); ?></div>
<div class="widget-body"><?php echoContent(); ?></div>
</div>
In functions.php
<?php
function echoTitle(){
$title = 'Add code to get title here';
echo $title;
}
function echoContent(){
$content = 'Add code to get content here';
echo $content;
}
Replace Add code to get title here and Add code to get content here with code to get contents ex:
$title = $_POST['title']; supposing you want get title by a submission form
I do not have enough details to tell you more.
I made a custom template for the team I'm working on. I used this code for the template (along with the parts that get the header and footer ofc)
<div class="main-container">
<?php
the_post();
$thumbnail = has_post_thumbnail();
?>
<section class="section-header overlay preserve3d">
<div class="background-image-holder parallax-background">
<?php the_post_thumbnail('full', array('class' => 'background-image')); ?>
</div>
</section>
<section>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="article-body">
<?php
if(!( $thumbnail ))
the_title('<h1>','</h1>');
the_content();
wp_link_pages();
?>
</div><!--end of article snippet-->
</div>
</div>
</div>
</section>
But if there's no featured image, a gray box will appear. I'd rather just have the whole section be hidden if there is no featured image, because it will look much better.
I'm a php rookie so I have no idea how to do this. What I think I need to do: Have an if/else statement check for the featured image. If there is no image, add a class to said section and define 'display none' in my css file for that class.
So this is the code I tried to pair with that, but it did not work:
<?php
// Must be inside a loop.
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
else {
$("section:first").addClass("noshow");
}
?>
Is this code incorrect? Where do I need to place this in my document for it to work?
While PHP is executed on the server, jquery is executed on the user end. You could always echo that jquery statement and that way it would be sent to the user.
You could follow the path Martin E. said on his comment (which in my opinion is a much cleaner version) or you could pursue the way you were working on by adding jquery on your header if you haven't and trying something like this:
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
else {
echo '<script>$("section:first").addClass("noshow");</script>';
}
?>
I created a custom page template for a wordpress theme , as long as I had the theme installed locally page was displayed and showed within it the custom post type associated with it , but when I loaded online theme and I created the page by selecting the template to be used the page content doesn't show up.
It seems that by selecting the page template is not created the page with this template , but creates a page with the content of the index.
this is my page code with the loop that shows a custom_post_type
<?php
/*
*Template Name: Partecipanti
*Description : Pagina che raggiude tutte le associazioni partecipanti
*/
?>
<?php get_header(); ?>
<div id="partecipanti" class="content-container row">
<h2 class="titolo-pagina"><?php the_title(); ?></h2>
<?php
$wpquery = new WP_Query(array(
'post_type' => 'partecipanti',
'posts_per_page' => -1,
));
while ($wpquery->have_posts()): $wpquery->the_post();
?>
<div class="container-partecipante col-lg-3 col-md-3 col-sm-4 col-xs-12 visible-xs">
<?php the_post_thumbnail() ?>
<h2 class="nome"><?php the_title() ?></h2>
</div>
<div class="flip-container container-partecipante col-lg-3 col-md-3 col-sm-4 col-xs-12 hidden-xs" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front">
<?php the_post_thumbnail() ?>
</div>
<div class="back">
<h2 class="nome"><?php the_title() ?></h2>
<a class="glyphicon glyphicon-plus" href="<?php the_permalink(); ?>"></a>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
Maybe you just forgot set Page Template in page's edit? Or it was bugged - try delete template, save page (to auto-remove page template), upload template, set it again and save.
Also check if page template is at all used - for example place plain HTML test before <div id="partecipanti" class="content-container row"> and check if is displayed.
Have you the same WordPress version and plugins installed? Maybe you missed changed setting?
Try with simple page template, for example default full-width - are editor content is displayed?
Or maybe you have the same bug like me with latest WP version - when page is child (have parent page), it's bugged and page template doesn't work + page is outputed as post instead page.
Check file permisions in your theme folder
I'm using the echo do_shortcode function to include an events calendar within a WP template. I need to display a custom field within the shortcode area, but can't get it to work. Below is my code. I need the custom field "tickets" to show in the a href="#" section (replacing the #).
The post is a custom post type called "event".
<?php echo do_shortcode('[eo_events]
<div class="date">
<div class="month">%start{M}%</div>
<div class="day">%start{j}%</div>
</div>
<div class="venue">
<h2 style="margin-bottom:-40px!important; padding-bottom:0;">%event_venue%</h2>
<br/>%event_venue_address%<br/>%event_venue_country%, %event_venue_postcode%
</div>
<div class="city"><h2>%event_venue_city%</h2></div>
<div class="tickets">
<h2>Tickets</h2>
</div>
[/eo_events]');
?>
get the custom field first and save it in a variable. You can use the variable later in the string.
<?php
$url = get_post_meta($post_id, 'tickets', true);
echo do_shortcode('[eo_events]
<div class="date"><div class="month">%start{M}%</div> <div class="day">%start{j}%</div></div> <div class="venue"><h2 style="margin-bottom:-40px!important; padding-bottom:0;">%event_venue%</h2> < br/> %event_venue_address%<br/>%event_venue_country%, %event_venue_postcode%</div> <div class="city" ><h2 >%event_venue_city%</h2></div> <div class="tickets">
<h2>Tickets</h2>
</div>
[/eo_events]');
?>
I have a shortcode that I put in my post but somehow it doent execute for some reasong. Here is the code I have:
short-code.php:
add_shortcode('teammate',function($atts){
$classes=$atts['country'];
$imgUrl=$atts['img'];
$name=$atts['name'];
$description=$atts['description'];
echo '
<div class="member "'.$classes.'>
<div class="member-img">
<img src="'.$imgUrl.'">
</div>
<div class="member-desc">
<h1>'.$name.'</h1>
<p>'.$description.'</p>
</div>
<div class="clear"> </div>
</div>
';
});
Here is how I include the file in functions.php:
$includes = array(
'includes/theme-options.php', // Options panel settings and custom settings
'includes/theme-functions.php', // Custom theme functions
'includes/theme-actions.php', // Theme actions & user defined hooks
'includes/theme-comments.php', // Custom comments/pingback loop
'includes/theme-js.php', // Load JavaScript via wp_enqueue_script
'includes/sidebar-init.php', // Initialize widgetized areas
'includes/theme-widgets.php', // Theme widgets
'includes/short-code.php', // Custom shortcode file for side menu
'includes/team.php' //team shortcode
);
and here is what i put in my page:
<div class="outer-members">
<div class="inner-members">
[teammate name="Darko Petkovski" img="http://myurl.com/myimage.jpg" description="test" country="mc"]
</div>
</div>
Seems that the code is working ok, but the only problem is that shortcode isn't executing outside wp.