When I click "read more" at the bottom of one of my website posts, it just loads the rest of the text in the same page and the same section, thus overflowing elements with text and spoiling my layout. I noticed there is a <!--more--> tag at the end of every Wordpress post when Read More is added from the toolbar. How can I override default behavior of this tag so that a new page is opened when a user clicks "Read More..." for a post?
Update:
Post content is loaded from a php file named tazeha.php using jQuery code.
tazeha.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<?php
require('wp-config.php');
?>
</head>
<body>
<?php
$cat_id=get_cat_ID('تازه ها');
$posts = get_posts ("cat=$cat_id&posts_per_page=1");
if ($posts)
{
foreach ($posts as $post):
setup_postdata($post); ?>
<h2><?php the_title(); ?></h2>
<?php the_content();?>
<?php endforeach;
}
?>
</body>
</html>
Can I change the code above so that the text after a post's "" tag opens up in a new browser page (tab)?
Following a Stackoverflow post, I added a single.php into my theme folder with the code below worked perfect i.e. my full post content is displayed in a new page when I click "read more..." link for any of my posts.
single.php
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<h3><?php the_category(' › '); echo " › "; the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
Related
I created a custom theme for word-press. When i say 'add new' page and i put content into this page it only displays the footer and header but dosnt hook my content which is in the CMS on that page.
This is what i have : page.php
<?php get_header(); ?>
<div class="row">
<div class="col-sm-12">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif;
?>
</div> <!-- /.col -->
</div> <!-- /.row -->
<?php get_footer(); ?>
Its been a long day what am i doing wrong here. Any tips please?
Would also like to make like a parent page from this new page, but its only option with page attributes are 'default template'.
If you didn't have a template part please use the_content() instead of
get_template_part( 'content', get_post_format() );
My actual problem, resolved. So i used 'advanced custom field' plugin for my WordPress. The problem using this is that it still requires you to do some coding.
I added a new page.
For that page I had an header image and content. So for ACF(advanced custom field) that is equal to two field types "Image --> field type and Text-Area --> field type"
Field name is what i used to call the fields to my .php page template.
Field Name : Image = header-image
Field Name : (2)Text Area = header-image-text-top (and) header-image-text-author
(I needed to display my text on the image thats why my div is just based on header image.)
So I hooked my page template and then added the the hooks for the fields i want to display on this page template.
page-stay.php :
<?php
/*Template Name: Stay - Parent Page */
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post=<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- <header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header>(you can use this if you need your page header to display)-->
<div class="enry-content">
<?php
$image = get_field('header-image');
if( !empty($image) ): ?>
<div class="head-image">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<div class="head-text-box">
<div class="head-text-box-holder">
<p class="headtext-quote"><?php the_field('header-image-text-top'); ?></p>
<p class="headtext-author"><?php the_field('header-image-text-bottom'); ?></p>
</div>
</div>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>
I'm trying to install the "Advanced AJAX Page Loader" plugin on my Wordpress site. The theme installation says to "make sure your theme has the content area wrapped in a tag such as a DIV with an id attribute called "content"".
My theme has what looks like a variable div wrapper around my content in the page.php file:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="page-<?php the_ID(); ?>" class="type-page" itemscope itemtype="http://schema.org/Article">
<!-- page-title -->
<?php if($themify->page_title != "yes"): ?>
<h1 class="page-title" itemprop="name"><?php the_title(); ?></h1>
<?php endif; ?>
<!-- /page-title -->
<div class="page-content entry-content" itemprop="articleBody">
<?php the_content(); ?>
My questions are, does it look like I am looking at the right section of code, i.e.
If so, how would I identify the corresponding div wrapper, which looks like it's variable based on page ID: ?
The instructions are asking you to wrap your content area in a div with an id of 'content'. Your code above doesn't have that;
<div id="content">
// content here
</div>
Below you can see my home page template. I used to have this line in the content of my page, it loads the thumbnail and the video player with video. I now want to have this in a template but i dont know how to call it properly. You can see I am trying to call the video from my theme options panel.
Before
[KGVID poster="http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg" width="1005" height="565"]http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/sample.mp4[/KGVID]
After
[KGVID poster="http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg" width="1005" height="565"]http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/sample.mp4[/KGVID]
Any help would be much appreciated.
<?php /* Template Name: Home Page */ get_header(); ?>
<!-- section -->
<section role="main">
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
[KGVID poster="http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg" width="1005" height="565"]<?php echo $smof_data['home-page-video-url'];?>[/KGVID]
</article>
<!-- /article -->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>
</section>
<!-- /section -->
<?php get_footer(); ?>
For using shortcode in templates do this
<?php echo do_shortcode("[KGVID poster='http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg' width='1005"' height='565']http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/sample.mp4[/KGVID]"); ?>
I'm struggling with getting wordpress to search custom post meta from a page template. I've looked all over the internet and can't seem to find anything that will work. No plugins seem to work either.
On my posts, I have the custom meta: "rate" and the value: "10" - Wordpress delivers no result when searching any of these.
I'd be very appreciated if someone could write me a searchpage.php page template or point me in the right direction (I'm not good with php).
Here's my current PHP code:
<?php
/*
Template Name: Search Custom Meta
*/
?>
<?php get_header(); ?>
<div id="content">
<div class="container clearfix fullwidth">
<div id="left-area">
<?php query_posts('meta_value='.$s); ?>
<?php if (!empty($wp_query->posts)) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
</div> <!-- end #left-area -->
</div> <!-- .container -->
</div> <!-- #content -->
<?php get_footer(); ?>
You checking incorrect variable in if so try removing that one,
query_posts('meta_value='.$s);
while ( have_posts() ) : the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
When I'm logged in to my site, viewing an individual post, the right sidebar displays perfectly, but when I log out on the same page (via the sidebar widget), the right sidebar suddenly ends up below my comments. This only happens with I'm viewing individual posts. Any ideas what causing this?
I've double checked the CSS, and as far as I can tell being logged out doesn't add or change any class attributes. Also - the theme I'm working with doesn't have a posts.php file...
Post: http://www.wespeakfashion.com/cool-sunglasses
page.php...
<?php include (TEMPLATEPATH . '/header.php'); ?>
<div id="content">
<?php include(TEMPLATEPATH."/l_sidebar.php");?>
<div id="contentleft">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(__('Read more'));?><div style="clear:both;"></div>
<!--
<?php trackback_rdf(); ?>
-->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
<?php posts_nav_link(' — ', __('« go back'), __('keep looking »')); ?>
</div>
<?php include(TEMPLATEPATH."/r_sidebar.php");?>
</div>
<!-- The main column ends -->
<?php get_footer(); ?>
The right sidebar appears to be in the main content div. This is suspicious because the left sidebar is a sibling of the main content div. Try taking the right sidebar out of there, and putting it as a sibling of the left sidebar and main content div.