In Wordpress, is there an official way to link from a single post view to that post type's index view? I'm working with custom post types. I've googled around for a wordpress function but there doesn't seem to be one for this and I'd like to avoid hardcoding a URL.
Thanks!
<a href="<?php bloginfo('url'); ?>" > Home </a>
Related
From the tag page I click a post.
When I get to the post page I want to show the relevant tag (the one I clicked).
Problem is that each of my posts has more then one tag. and using get_the_tags() get me the whole list of tags related to the post.
How can I identify and show only the relevant tag from the array?
Is there anyway to pass this information to the single.php page?
at the end I passed the tag name with the post URL and used $_GET to read it back on the post page.
on tag page:
<a href="<?php the_permalink()?>?tagName=<?php single_tag_title(); ?>">
on post page:
<?php echo $_GET["tagName"]; ?>
I have this href link which is dynamically posted, I want to get the single.php file and the dynamically posts to be redirected to my single.php file Here is my link below:
<a href="/single-<?php the_ID();?>-<?php the_slug(); ?>" class="wrapper" style="background-image:url('<?=$url?>')">
When I click on the link the URL is this way:
/single-137-2014-inaugural-diversity-abroad-conference-4
And I want that page to be redirected to my single.php file. How will I be able to do this?
Any help is muchl appreciated. TIA
I have solved your problem but please read about the get_permalink() function
<a href="<?php echo get_permalink(); ?>" class="wrapper" style="background-image:url('<?=$url?>')">
get_permalink() - Retrieves full permalink (link of a post) for the current post or post ID. This link will be opened post single page, which means if this is a custom post type and you create it as a separate single-post-type.php, then it will be as an open single-post-type.php page. Otherwise it appears as single.php.
For your information, posts have been opened in single.page while page opened with page.php. read about this link https://codex.wordpress.org/Post_Type_Templates
Hi i have this page template past conferences single and i have this href tag
<a href="/past-conferences-single/<?php the_slug(); ?>" class="wrapper" style="background-image:url('<?=$url?>')">
and my href link goes this way
past-conference-single/2013-inagural-diversity-abroad-conference-5/
i want that when i click on this page goes to this page template past-conference-single and with the content is dynamic based on the slug.
How will i able to do this?
Any help is muchly appreiciated. TIA
I'm trying to create a slider on the homepage of my Magento site. I am totally new to Magento and have someone else on our team coding most of that stuff after realizing how far into the deep end I jumped.
My issue: I'm trying to pull custom posts from WP (with the paid advanced custom fields extension) to display an image that will go into a slider.
I'm stuck at the most basic part - pulling in a list of Wordpress posts.
I created a new file: mytemplatedirectory/default/template/home/slider.phtml with
<?php $posts = $this->getPosts() ?>
<?php foreach ($posts as $_post) : ?>
<?php echo $post->getPostContent() ?>
<?php endforeach ?>
and I put this into the CMS page in the Magento admin:
{{block type="core/template" template="home/slider.phtml"}}
But not even the default post is showing up.
If anyone has any guidance that would be extremely helpful. The beginning steps are what are throwing me off but it would also be nice to have help pulling the custom post and the advanced custom field (although it seems that Fishpig's documentation makes this pretty simple).
Thanks in advance! Sorry for such an amateur question.
The block type you're using does not include the getPosts() method, which is the reason your call to this returns nothing. If you change the block type to 'wordpress/sidebar_widget_posts' then the call to getPosts will return a post collection object.
The following link explains a little bit more about how to include this block and what you can do with it:
Display WordPress Blog Posts on the Magento homepage
Figured this out with Ben's help (who I believe is the creator of the excellent Fishpig extension).
I created a custom post (with the Custom Post Type UI plugin for WP) and a custom field (with the Advanced Custom Fields plugin for WP).
On my Homepage in the CMS I added in the content area
{{block type="wordpress/sidebar_widget_posts" name="wordpress.widget.recent_posts" post_count="5" post_type="slider_home" template="wordpress/sidebar/widget/slider_home.phtml"}}
In that block, slider_home is my post type and slider_home.phtml is a new file I created that pulls the code from wordpress/sidebar/widget/posts.phtml but customizes it to my need.
Within the loop in slider_home.phtml I took out what was currently there and added:
<?php $image = $post->getMetaValue('image'); ?>
<?php $url = $post->getMetaValue('url'); ?>
<a href="<?php echo $url; ?>" target="_blank">
<img src="<?php echo $image; ?>" />
</a>
which is pulling in the custom fields I made in Wordpress. works perfectly and now my client will be able to update their Magento site through the Wordpress CMS.
I have a wordpress site with categories containing youtube videos. So for example i have a category cinema and when you click it you see a sticky post with the youtube video on top and afterwards the titles of the rest of the youtube videos i have for this category. When i click one of the titles the single.php is loaded and i see the youtube video.
My question is: how do I edit the code so in the category-cinema.php when i click one of the titles the video is loaded there without loading the single.php file?
if clicking on a link does not jump to a page, I think you need to use Javascript to accomplish that. then you can go to the archive.php and modify the title link(something like below) inside the loop. :
<h1 class="artitle"><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></h1>