I'm trying to modify a plugin which sends out url's in an email notification.
The code in the plugin is this
<?php the_title(); ?>: <?php the_job_permalink(); ?>
It displays the following in the email
Front End Risk Account Manager: http://tbc-recruit.com/job/front-end-risk-account-manager/
What I'd like to end up with is a url in this format
http://tbc-recruit.com/job/front-end-risk-account-manager/?utm_source=jobalerts&utm_medium=email
I have tried the following
<?php
$alerturl = the_job_permalink();
$alerturl .= "?utm_source=jobalerts&utm_medium=email";
?>
<?php the_title(); ?>:<?php echo $alerturl; ?>
That code gives the following output
Front End Risk Account Manager:?utm_source=jobalerts&utm_medium=email
Maybe because the_job_permalink() show html content like
http://tbc-recruit.com/job/front-end-risk-account-manager/
You should use get_permalink()
<?php
$alerturl = get_permalink() . '?utm_source=jobalerts&utm_medium=email';
?>
<?php the_title(); ?>:<?php echo ' ' . $alerturl . ''; ?>
I hope this helped you
Use get_the_title() instead of the_title()
Related
my wordpress theme i created shows just the first timestamp of the first article of multiple article on the page. On the rest of them there is just a empty space, so php generated no echo.
I think that there is something wrong with the loop, but i found similar loops on the wp page. Can someone help me ?
here is my code
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="entry">
<h2 class="title"><?php the_title(); ?></h2>
<div class="time-text">added on: <?php the_date('d.m.Y'); ?> - Author: <?php the_author(); ?></div>
<div id="text_post" style="margin-top:20px;">
<?php the_content(); ?>
</div></div>
<?php endwhile;endif?>
It's how the the_date function works. Quoting the "special note" on that page:
SPECIAL NOTE: When there are multiple posts on a page published under
the SAME DAY, the_date() only displays the date for the first post
(that is, the first instance of the_date()). To repeat the date for
posts published under the same day, you should use the Template Tag
the_time() or get_the_date() (since 3.0) with a date-specific format
string.
Try using <?php echo get_the_date('d.m.Y'); ?> instead of <?php the_date('d.m.Y'); ?>. That's untested - I'm just going by that quote.
First you need to open these three files:
index.php
single.php
page.php
Then you will need to locate the following code:
<?php the_modified_time('F jS, Y');?>
Note: Since there are so many formats of displaying dates, you might not see the exact code, but something along this line.
Replace it with:
<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
echo "and last modified on ";
the_modified_time('F jS, Y');
echo " at ";
the_modified_time();
echo ", "; } ?>
This href I have on a page is included in a cycle 2 slider so a caption under an image. BUT it doesn't work when clicking and it opening a new tab, it only works when you right click and then click "go to ....". Does anyone know why?
The plugin on wordpress: http://www.advancedcustomfields.com/
Code:
<a class="alt-caption" href="http://<?php the_field('url_site'); ?>"><?php the_field('url_site'); ?></a>
<div class="paginawrap no_overflow">
<div class="wraptest">
<div class="cycle-slideshow"
data-cycle-fx="carousel"
data-cycle-speed="500"
data-cycle-delay=5000
data-cycle-next=" > img"
data-cycle-caption=".alt-caption"
data-cycle-caption-template="{{alt}}"
data-cycle-carousel-fluid=true
data-allow-wrap=false
>
<?php $args = array(
'post_type' => 'project',
'posts_per_page' => 10
);
$query = new WP_Query( $args );
if ( $query->have_posts()) :
while ( $query->have_posts()) : $query->the_post();
the_post_thumbnail('home');
endwhile; wp_reset_postdata();
endif; ?>
<div class="alt-caption"></div>
</div>
<div class="archief1">
</div>
</div>
</div>
Your href is empty. Let's have a look at your source code:
<a class="alt-caption external" href="http://">www.aimassociates.nl</a>
The href attribute is looking at "http://".
Maybe you must add an echo?
<?php echo the_field('url_site'); ?>
It's weird that the same PHP code returns different result, have you copy/paste the code just as is in your files?
Why don't you try this?
<?php $site_url = the_field('url_site'); ?>
<a class="alt-caption" href="http://<?php echo $site_url; ?>"><?php echo $site_url; ?></a>
You use php to load the link. Why not use php the entire way for that line of code? Something like this:
echo('<a class="alt-caption" href="' . $the_field . '" target="_blank"><' . $the_field . '></a>');
Also make sure that your homepage correctly reads the php data.
I have this:
<?php echo $this->htmlLink($this->viewer()->getHref(), $this->itemPhoto($this->viewer(), 'thumb.icon')); ?>
That generates an HTML code like:
<a href="http://www.domain.com/john">
<img src="http://www.domain.com/thumb_0205.jpg" alt="" class="thumb_icon item_photo_user thumb_icon">
</a>
Now, what I am trying to do, is to add:
<?php echo $this->viewer()->getTitle(); ?> //This will generate the member's name, like "John Doe"
to the code above, to generate an HTML code like:
<a href="http://www.domain.com/john">
<img src="http://www.domain.com/thumb_0205.jpg" alt="" class="thumb_icon item_photo_user thumb_icon">
<span>John Doe</span>
</a>
Anyway I can do that?
Thanks
This ought to work:
<?php echo $this->htmlLink(
$this->viewer()->getHref(),
$this->itemPhoto($this->viewer(), 'thumb.icon') . '<span>' . $this->viewer()->getTitle() . '</span>'
); ?>
Guessing, this should work:
<?php echo $this->htmlLink($this->viewer()->getHref(), $this->itemPhoto($this->viewer(), 'thumb.icon').'<span>'. $this->viewer()->getTitle().'</span>'); ?>
Just append the extra string to the second argument of htmlLink.
HtmlLink($href, $text, $title = "", array $attribs = array());
I want to make the joomla articles intro image to behave like the read more, and the title link. So the user clicks the image, and the article loads.
I'm not an PHP expert but maybe this is the readmore links code:
<a href="<?php echo $this->item->readmore_link; ?>" class="button<?php echo $this->item->params->get('pageclass_sfx'); ?>">
<?php if ($this->item->readmore_register) :
echo JText::_('Register to read more...');
elseif ($readmore = $this->item->params->get('readmore')) :
echo $readmore;
else :
echo JText::_("Read Article");
endif; ?></a>
This is what i want to do with every intro image on my joomla site.
Thanks !
Just resolved it!
your way of thinking helped me. Thank you!
here's my code:
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>">
<?php
$images = json_decode($item->images);
if (isset($images->image_intro) and !empty($images->image_intro)) {
$imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro;
$class = (htmlspecialchars($imgfloat) != 'none') ? ' class="size-auto align-'.htmlspecialchars($imgfloat).'"' : ' class="size-auto"';
$title = ($images->image_intro_caption) ? ' title="'.htmlspecialchars($images->image_intro_caption).'"' : '';
echo '<img'.$class.$title.' src="'.htmlspecialchars($images->image_intro).'" alt="'.htmlspecialchars($images->image_intro_alt).'" />';
}
echo $this->item->introtext;
?>
</a>
for Joomla 2.5:
in your override for _item.php (Location: yourtemplate\html\mod_articles_news\item.php)
place the following line:
<?php if ($params->get('image')) : ?>
<?php $images = json_decode($item->images); ?>
<?php if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
<img src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
<?php endif; ?>
<?php endif; ?>
Place it there where you would like it to show up
For example after:
<?php echo $item->beforeDisplayContent; ?>
Your intro image has become a link now.
the isset part, makes sure that if a viewer uses Internet Explorer, it doesn't show up a small red cross box.
Just for the information:
in blog_item.php you can find an example code how it's shown up in an article. Here you can also find the code for imagefloat etc.
<?php if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
<?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>">
<img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
</div>
<?php endif; ?>
So let me start by explaining what the code that you've posted above does. The entire block of code generates one link: there are a bunch of if statements that are determined based off some settings. For example, if you have set that people need to register in order to read more, the link will say "Register to read more..."
The part that we're interested in here, however, since we want to turn images into links, is the URL that we want the images to link to. This is right in the first line:
<a href="<?php echo $this->item->readmore_link; ?>"
so we know that the URL is provided dynamically thanks to $item->item->readmore_link and all this code is doing is echoing it into the HTML.
All that's left is to edit your Joomla template of the page on which you have your images (probably the same file you took this code from). It looks like this should be part of a greater PHP loop, which loops through all the posts. Somewhere above where you found this code, should be code for the intro image that goes along with that post.
I'm not sure what it'll look like, it could be a <img src="<? stuff here; ?> /> or it could be dynamically generated. Keep reading. If you're still not sure where to find it at the end, edit your post with the full code of the template where you got the above snipping from. Regardless of what it looks like, it is referred to as <WHATEVER IMAGE CODE YOU FOUND ABOVE> in the following step:
You have to wrap that image with "a" tags so that it looks like the following:
<WHATEVER IMAGE CODE YOU FOUND ABOVE>
That should do it. Let me know if you have any trouble, I'll be more than happy to make my post more specific if you can provide more detailed information, but I've tried to explain it well enough that you should be able to figure it out with a couple tries.
As you stated you are not a PHP expert, it sounds like your best bet will be to use a Joomla extension that has similar functionality to what you want.
I believe mod_minifrontpage will work for what you need. It allows you to display a list of articles, and it generates thumbnails for those articles based on the first image to be referenced.
There are article intro images in J, since 1.7.5 and now in latest 2.5.3
what you need is change the defaults for component_content,
you can do it 2 ways, editing views in yourinstall/components/com_content/views/
or use template overrides , you first need to know if your template IS using overrides otherwise if you edit component views in the component itself you will not see changes.
to verify this , go to
site_name/templates/template_name/html folder and check if there is folder name
com_content ,
if that is the case than your template is using overrides and any edits should be done trough there not through component
now to the actual code
this is in
components\com_content\views\featured\tmpl\default_item.php ( THIS I DEFAULT FRONTPAGE ARTICLE VIEW)
<?php if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
<?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>">
<img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
</div>
<?php endif; ?>
all you would need to do is wrap a element around IMG tag with readmore link like this
<a href="<?php echo $this->item->readmore_link; ?>">
<img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
</a>
DO NOT forget that if there is template override for com_content you wold need to edit the featured/default_item.php inside it
In Joomla 3.1, the intro_image layout has been moved to the layouts/joomla/content folder. In my situation, it is called from com_content/views/category/tmpl/blog_item.php like so:
<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
I moved that file to my template/html/com_content/category/blog_item.php and then wrapped the call to JLayoutHelper like so:
<?php $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>
<a href="<?php echo $link; ?>">
<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
</a>
If you have Gantry installed on Joomla 3.1, the overrides are in a different location. You will want to navigate to plugins/system/gantry/overrides/3.0/2.5/com_content/category/blog_item.php and wrap the intro image with the read more link code.
<?php $link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>
<a href="<?php echo $link; ?>"><img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/></a>
Using the magicfields 2.0 plugin for Wordpress 3.1.
Here's the broken page:
http://sseko.wecreativeagency.com/style/
and here's a page with it working:
http://sseko.wecreativeagency.com/university-bound/
Note the footer on the first page is receiving the id info from the magicfields
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>">
<?php the_content(); ?>
<div id="note" class="grid_12"><p class="note grid_6 alpha"><span class="special">Style your Ssekos!</span> There are so many ways to tie your Ssekos. Watch the videos and learn how! Then, come up with your own!</p><h1 class="grid_6 omega"><?php wp_title(' ','true','right'); ?></h1></div>
<?php $styles = getFieldOrder('image');
if(is_array($styles))
{foreach($styles as $style)
{
echo "<div class='grid_3'>";
echo "<a rel='styles' href='#info$style'class='inlineimg grid_3'>";
echo "<img src='";
echo get_image('image',1,$style,$tag_img=0);
echo "'class='grid_3' title='";
echo get('name',1,$style);
echo "'alt='";
echo get('name',1,$style);
echo "'";
echo "</a>";
echo "<h2 class='grid_3'>";
echo get('name',1,$style);
echo "</h2></div>";
echo "<div style='display:none'><div id='info$style' class='grid_8 lightbox'>";
echo get('link',1,$style);
echo "</div></div>";
}
}
?>
<div class="clear"></div>
</article>
<?php endwhile; endif; ?>
I've check the database for extra entries but I can't find the reason for it continuing to iterate out into the elements below.
For some reason I could not check your site .. but I believe this is hapenning because you have 2 nested loops ..
One is the Wordpress loop if--> while , and then your Foreach loop.
When the Wordpress loop encounters posts , it will iterate your second loop FOR EACH ONE of the posts ...
for example, on a page where there are 10 $post, it will iterate 10 times for each $style ...
When you have 1 post , it will iterate once .
Like I said, for some reason your site was not available to me , but seeing your URL construction, My guess is that it does not work on the first example, because it is some kind of category (which returns multiple posts ) and the second url is a SINGLE post ...