Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How to display all pages (different page templates) on one page
for ex : About , portfolio , resume , contact etc in one page
i want to display each page in a div in index.php
this is really simple implementation, add the below code in your index.php
Modify ID for page destiny.
you have create div´s in HTML
<?php $page_id = XXX; //Page ID
$page_data = get_page( $page_id );
//Guardar variáveis
$title = $page_data->post_title;
$content = apply_filters('get_the_content', $page_data->post_content);?>
<div id="box-title">
<div id="titulo-publicidade">
<?php echo $title; //Show title ?>
</div>
<div id="box-content">
<?php echo $content; //Show content ?>
</div>
</div>
Good Luck.
EDIT
I have not tried, but it would be something like this
<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
$content = $page->post_content;
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content );
?>
<h2><?php echo $page->post_title; ?></h2>
<div class="entry"><?php echo $content; ?></div>
<?php
}
?>
Related
I'm trying to filter data from a custom post-type called "Clients", based on category. What I need to appear is the logo for each particular client.
I've set up a repeater field of Post Objects, so I can change the order that the logos will be displayed.
What I have currently works, however I cannot figure out how to incorporate the Post Object selector, so that what appears is determined by the instances I've added via the Repeater.
Here is the link to the site. Appreciate any answers!
See below for screenshot of my dashboard setup:
<ul id="filters">
<?php
$terms = get_terms("category", array(
'orderby' => 'slug'
)); // get all categories, but you can use any taxonomy
$count = count($terms); //How many are they?
if ( $count > 0 ){ //If there are more than 0 terms
foreach ( $terms as $term ) { //for each term:
echo "<li><a href='#' data-filter='.".$term->slug."'>" . $term->name . "</a></li>\n";
//create a list item with the current term slug for sorting, and name for label
}
}
?>
</ul>
<?php $the_query = new WP_Query(array(
'post_type' => 'clients',
'posts_per_page' => '-1',
'order' => 'ASC'
)); //Check the WP_Query docs to see how you can limit which posts to display ?>
<?php if ( $the_query->have_posts() ) : ?>
<div class="isotope-list-container">
<div id="isotope-list" class="row small-up-1 medium-up-2 large-up-3">
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
$termsArray = get_the_terms( $post->ID, "category" ); //Get the terms for this particular item
$termsString = ""; //initialize the string that will contain the terms
foreach ( $termsArray as $term ) { // for each term
$termsString .= $term->slug.' '; //create a string that has all the slugs
}
?>
<div class="<?php echo $termsString; ?> portfolio columns"> <?php // 'portfolio' is used as an identifier (see Setp 5, line 6) ?>
<div class="portfolio-item-container">
<?php
$image = get_field('logo');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
</div> <!-- end portfolio item -->
<?php endwhile; ?>
</div> <!-- end isotope-list -->
</div>
<?php endif; ?>
<?php wp_reset_query(); ?>
I was able to make this considerably simpler by using the Post Types Order plugin to reorder my posts.
https://wordpress.org/plugins/post-types-order/
I would like to prevent the post's gallery from displaying when the post is listed on the homepage.
I'm thinking it will utilize add_filter and apply_filter when post in on homepage.
You can add a gallery to posts by clicking the add media button. You can select existing images or upload additional images that will create a gallery within the post. This embeds a shortcode in $post['content'] that looks like [gallery ids="37,38,39,40,41,42].
The issue is that by default it displays when the post is included on homepage as well as the individual post itself.
Update: This is what I am doing right now to achieve the requirement. I suspect there will be a more elegant way.
<div class="entry-content">
<!-- Begin Post Content -->
<?php if ( is_single() ) : ?>
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'faceboard' ) ); ?>
<?php else : // Filter Gallery ShortCode out ?>
<?php
$content = '';
$content = get_the_content();
$content = preg_replace('/\[gallery\sids="[0-9]+(,[0-9]+)*,?"\s?(royalslider="\d")?\]/s',"",$content);
echo wpautop( $content, 1);
?>
<?php endif; // is_single() ?>
<!-- End Post Content -->
<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'faceboard' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
You can add the following to your theme's functions.php file or to a custom plugin (better, as you can disable it without touching the theme).
The filter post_gallery is used to create your own gallery, and the $content parameter comes empty by default. If it returns empty, the original [gallery] shortcode is processed.
Here, we are using a dummy empty value, so the filter is tricked into thinking that we are passing some actual gallery content, but it's just a white space.
add_filter( 'post_gallery', 'disable_home_galleries_so_17635042', 10, 2 );
function disable_home_galleries_so_17635042( $content, $atts )
{
// http://codex.wordpress.org/Conditional_Tags
if( is_home() )
return ' ';
return $content;
}
I'm creating a simple theme using Twitter's Bootstrap. I am only using wordpress for the blog portion of my website (http://www.mattaltepeter.com/n3). In my single.php file i use to pull in the comments template. Ultimately I would like to use Jetpack comments, but just trying to use the default wordpress one currently. I have created a test post and added a couple comments to it, but the comments do not show up on the post. I switched my theme to twenty-eleven and they did, so it has to be something with my theme. I think the issue is with my comments.php. I'm not entirely sure what to put in there to make it work. I started working on this awhile ago and cannot remember where I got the code that currently resides in comments.php. I tried to copy and paste the code from the twenty-eleven comments.php, but that didn't work either. Do I need to write custom code for this or what?
Thanks for the help!
Matt
Try using this. This is what I use to call comments.
In functions.php:
function custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
$GLOBALS['comment_depth'] = $depth;
?>
<li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
<div class="comment-author vcard"><?php commenter_link() ?></div>
<div class="comment-meta"><?php printf(__('Posted %1$s at %2$s <span class="meta-sep">|</span> Permalink', 'your-theme'),
get_comment_date(),
get_comment_time(),
'#comment-' . get_comment_ID() );
edit_comment_link(__('Edit', 'your-theme'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
<?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'your-theme') ?>
<div class="comment-content">
<?php comment_text() ?>
</div>
<?php // echo the comment reply link
if($args['type'] == 'all' || get_comment_type() == 'comment') :
comment_reply_link(array_merge($args, array(
'reply_text' => __('Reply','your-theme'),
'login_text' => __('Log in to reply.','your-theme'),
'depth' => $depth,
'before' => '<div class="comment-reply-link">',
'after' => '</div>'
)));
endif;
?>
<?php } // end custom_comments
In your post, within the loop:
<?php if ( ('open' == $post->comment_status) && ('open' == $post->ping_status) ) : // Comments and trackbacks open ?>
<?php printf( __( '<a class="comment-link" href="#respond" title="Post a comment">Post a comment</a> or leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'your-theme' ), get_trackback_url() ) ?>
<?php elseif ( !('open' == $post->comment_status) && ('open' == $post->ping_status) ) : // Only trackbacks open ?>
<?php printf( __( 'Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'your-theme' ), get_trackback_url() ) ?>
<?php elseif ( ('open' == $post->comment_status) && !('open' == $post->ping_status) ) : // Only comments open ?>
<?php _e( 'Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'your-theme' ) ?>
<?php elseif ( !('open' == $post->comment_status) && !('open' == $post->ping_status) ) : // Comments and trackbacks closed ?>
<?php _e( 'Both comments and trackbacks are currently closed.', 'your-theme' ) ?>
<?php comments_template('', true); ?>
I have this custom post type Gallery. I want to call first image from the posts.
<?php
$item_count = 1;
$args = array( 'post_type' => 'gallery', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
$item_count = 1;
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title(); ?>
<div class="count"><?php echo $item_count; ?></div>
<div class="thumbnail">
// THE FIRST GALLERY ATTACHMENT IMAGE
</div>
<?php $item_count++; ?>
<?php endwhile; ?>
Any ideas?
Note: I added Gallery no simple image on the post!
Check this WordPress Codex example.
The code will show the first image associated with the post.
Or check this WordPress forum discussion that also deals with this problem.
UPDATE:
Go to Appearance > Editor and select Theme functions (functions.php).
at the end of the file add this:
// Get URL of first image in a post
function catch_that_image($my_postid) {
global $post;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_post_field('post_content', $my_postid), $matches);
$first_img = $matches [1] [0];
// no image found display default image instead
if(empty($first_img)){
$first_img = "/images/default.jpg";
}
return $first_img;
} ?>
Now in your code you modify this part of the code:
<div class="thumbnail">
<?php echo catch_that_image($loop->ID) ?>
</div>
UPDATE V2
I modified the code to suit your code.
UPDATE V3
I tried the code on my development site and I modified it further until the code worked as it should. You should not have any problems now.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a problem with my wordpress blog here(http://muraliprashanth.me) everything seems to be working fine but the problem is after each post i am appending author information like the image below
but when i click on the
View all posts by Murali Prashanth hyperlink
it's redirecting me to this URL http://muraliprashanth.me/author/Murali%20Prashanth/
I don't know where to create the author profile page or does my wordpress theme supports author profile pages or not Please suggest me i am struggling to resolve this issue from past 3 months, Help is much appreciated.
Thanks in advance.
These two links have the details about the author profile linking as well as template information. Have a look and see if you are able to fix it.
http://codex.wordpress.org/Author_Templates
http://codex.wordpress.org/Function_Reference/the_author_url
Try it. I 've given my author.php file for usage.
<?php
/**
* The template for displaying Author Archive pages.
*
* #package WordPress
*/
get_header(); ?>
<?php
if ( have_posts() )
the_post();
?>
<h1><?php printf( __( 'Author Archives: %s' ), "<span class='vcard'><a class='url fn n' href='" . get_author_posts_url( get_the_author_meta( 'ID' ) ) . "' title='" . esc_attr( get_the_author() ) . "' rel='me'>" . get_the_author() . "</a></span>" ); ?></h1>
<?php
// If a user has filled out their description, show a bio on their entries.
if ( get_the_author_meta( 'description' ) ) : ?>
<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'avatar_size', 60 ) ); ?>
<h2><?php printf( __( 'About %s', 'theme' ), get_the_author() ); ?></h2>
<?php the_author_meta( 'description' ); ?>
<?php endif; ?>
<?php
rewind_posts();
get_template_part( 'loop', 'author' );
?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>