How can I display <?php the_content(); ? in a non-single page without the Read More link?
Basically I just need to get the part of the post before the more tag as I have a separate Read More button with a href="<?php the_permalink() ?>"
Most likely you either want to use
the_excerpt()
or
the_content(''); //'' tells it to have no text for the link
Related
So I am currently using the following script (effect 3):
http://tympanus.net/codrops/2013/06/18/caption-hover-effects/
I am trying to make these boxes show on my blog content listings, which currently uses the content feature. I have included the call for the CSS and JS of the demo file for this effect;
<link rel="stylesheet" type="text/css" href="css/default.css" />
<link rel="stylesheet" type="text/css" href="css/component.css" />
<script src="js/modernizr.custom.js"></script>
I have added this to the index.php file rather than the header, as I only need it on this page. Currently, I have this so only the featured image/embed shows for the blog listing. I removed any wordpress title and excerpt tags as I wanted to focus on getting this to work before adding in the content. So, currently, it's just a copy of the code used in the demo combined with the code for the blog listing itself. Shown here is the image post.
<ul class="grid cs-style-3">
<li>
<figure>
<?php
}
if ($format === 'image') { ?>
<?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="post-image" >
<?php the_post_thumbnail(); ?>
</a>
<figcaption>
<h3>Settings</h3>
<span>Jacob Cummings</span>
Take a look
</figcaption>
</figure>
This is where I am getting a little bit lost and maybe this is down to too many scripts on the same page, as the blog listing itself uses webkit coding to display. But I have copied all the code exactly as it was in the demo, minus the image section which is my blog code instead. But no matter what I try it just shows without the effect and under the image. I am completely lost as to what to do here and out of ideas.
I have tried searching, but nothing has helped. So I am thinking this is more down to the coding I already have for the theme not playing nicely with this code. I have managed to add additional sections in the same way, but not get extra code to work with the themes functions itself.
You can see the page I am referring to and where it has gone wrong here, under any of the images:
http://outside.hobhob.uk/test/blog/
Happy to provide anything else extra.
Full code: http://hostcode.sourceforge.net/view/6152
The code you posted has some problems, try replacing it with this. I just removed the brachet I was talking about in the comment, and added the endif;s at the end of the block. I still have no idea if the $format variable is correctly populated elsewhere in your code, so there may be other issues.
<figure>
<?php if ($format === 'image') : ?>
<?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="post-image" >
<?php the_post_thumbnail(); ?>
</a>
<figcaption>
<h3>Settings</h3>
<span>Jacob Cummings</span>
Take a look
</figcaption>
<?php endif; ?>
<?php endif; ?>
</figure>
I'm new to php coding and I need to fix a bug in my friend's website. Here is the page with the bug http://www.corectura.ro/category/in-presa/ (it's in Romanian, but it doesn't matter). "Citeste mai multe..." is the "Read more..." link and it doesn't work. It just opens the same page (this one: http://www.corectura.ro/category/in-presa/) in a new tab, instead of opening the link/post in order to read more just as the "read more..." button says. The site is on Wordpress platform and has a custom theme.
I've looked into the editor in all the php files for the section where the "read more" is mentioned. I only found it in archive.php and styles.css.
In the styles sheet the only code i found is this one (regarding to the read more link)
.r_more{ display:block; text-align:right; }
And in the archive.php the code below:
<li>
<div class="post_thumbnail"><?php the_post_thumbnail('thumbnail'); ?></div>
<div class="post_content"><h3><?php the_title(); ?></h3>
<div class="date_post"><?php echo ucfirst(get_the_date('F Y')); ?></div>
<?php the_excerpt();
echo 'Citeşte mai multe...';
?>
</div>
</li>
Is there something wrong with this code? Is the syntax correct? Why does it open the same page in a new tab instead of opening the page with the content that's needed to be shown after clicking "Citeste mai multe..." ("Read more...")?
Please help. Thank you.
You are using echo, so you need to change the_permalink() to get_permalink() (which returns the permalink):
echo 'Citeşte mai multe...';
Try this instead:
<?php the_excerpt(); ?>
Citeşte mai multe...
I am trying to add data atributes to my anchor tag for a WordPress custom theme.
The code below is what I've so far, the problem is with plain HTML this works fine but once I add the PHP lines then something breaks.
When the actual HTML is rendered it excludes the end of the open anchor tag, and leaves "> out to display on the page.
Not sure what went wrong but maybe someone can take a look at this and might be able to point out what I did wrong, a fix, a better way, or maybe if this is even possible.
<a
class="caption" href="<?php the_permalink()?>"
title="<?php the_title_attribute(); ?>"
data-title="<?php the_title(); ?>"
data-description="<?php the_excerpt(); ?>"
>
<?php the_post_thumbnail(array(301,301)); ?>
</a>
<?php endif; endif; ?>
This is not an answer, just some thoughts/things to try:
Are those PHP functions defined somewhere on the same page, or on a page that is included or required ?
Have you tried replacing those function calls with simple PHP commands, such as <?php echo "the_permalink_goes_here"; ?> etc. -- just to make sure, for example, that the anchor tag's href value changes to
<a href="the_permalink_goes_here" etc>
The excerpt function that you're using for the description is returning not just the excerpt, but also an additional "Read more" link, effectively putting an anchor inside your anchor tag, which is what is breaking it. To the best of my knowledge, there isn't a default WP function for returning an excerpt without this link, so you will need a function to do this. Try searching for 'excerpt without link'
I'm currently using Wordpress and I have website listings that has link names as titles (eg. www.test.com, www.test2.com)
With this php code, it calls out the name of the website link:
<h3 class="list"><a class="h1" href="<?php the_permalink(); ?>"><?php the_title(); ?></h3>
Now that website has a "readmore" button and a "visit website" button. I'd like to turn the "visit website" button into a external link using PHP.
For example, the website listing is called "www.test.com". I'd like to turn the "visit website button" into an external link that will make it go to "www.test.com".
Here is my html code for the "visit website button":
<div id="visit">
Visit website
</div>
I hope someone can help.
Thanks!
I suppose you could do something like this instead
<h3 class="list"><a class="h1" href="http://<?php the_title(); ?>">Visit Website</h3>
If the_title is a valid URL starting with www (not http://), then it'll work. If they already have http:// in the title, remove that part.
Whenever you click a link you are visiting the url specified in href attribute.
For example to create a link, to go to google.com I would do this
Go to Google
So in you case you replace # with your link
<div id="visit">
Visit website
</div>
code it in php:All i can think of is this code:
<?php echo "<a href='http://www.test.com'>visit site</a>" ?>
I guess you are confused by
<?php the_permalink(); ?>
the_permalink(); calls get_permalink(); which finally provides the link.You can see its source code in wp-includes/link-template.php.
I'm trying to construct a Table of Content on a custom template in Wordpress. Because I already know beforehand the headings of the internal sections I want to link to I hardcoded that into the template.
My problem is that in Wordpress it doesn't scroll to that section at all? Here's the link to a page with an existing TOC section that's not working.
In terms of code, this is an illustration of what I got:
<div class="table_content">
<h4>Table of Contents</h4>
<ol>
<li>Overview</li>
</ol>
</div>
Which should link to an internal section with the code:
<h2><a id="#test_link" class="internal"><?php the_title(); ?></a></h2>
Note: I'm using "ID" instead of "name" because it's deprecated in HTML5, which is the doctype I'm using.
I'm also wondering is there an easier way of doing this with jQuery?
Any help in saving my hairline would be GREATLY appreciated...
Nevermind, I'm a muppet.
It's got nothing to do with doctypes or Wordpress issues. Just my incorrect, sleep-deprived implementation of HTML.
This
<h2><a id="#test_link" class="internal"><?php the_title(); ?></a></h2>
should be
<h2><a id="test_link" class="internal"><?php the_title(); ?></a></h2>
Notice the missing "#" in the "ID" attribute, removing that makes everything work nicely :)
You don't need the separate a element...
http://www.yourhtmlsource.com/text/internallinks.html