WordPress post details - wordpress

I have WordPress page in which post titles of a single category are showed. When the user clicks any of the post a new tab should open and show the details of the post on which the user clicked how will I do this.

This is just simple the page where you found the list of post title is your "archive" or "category" page check where it's from coming. in that template give the link to your title like <a href="<?php echo get_permalink( $post->ID ) ?>"> which link you your single.php file in that change accordingly.

Related

How to Make Brand name on product page- clickable using shortcodes, plugin- Brands for woocommerce

I am using flatsome theme and have to design custom product page. I am using Brands for Woocommerce plugin. I got the Brand name above the Title through [product_brands_info type=’name’]. But I want it to be clickable so that it should redirect to the specific brand page. Pls help
http://artpoint.edupox.com/product/untitled-4/
I have checked the plugin and seems there is no options for linking with this shortcode but in this shortcode you can easily add codes using these two actions. These actions will work before and after the shortcodes content.
Add these codes in your activated theme's functions.php file. If you want you can also add target="_blank" in the <a> tag as it is an external link.
add_action('product_brands_info_before', 'add_brand_link_start');
function add_brand_link_start($term){
$brand_url = get_term_meta( $term->term_id, 'br_brand_url', true );
?>
<a href="<?php echo esc_url($brand_url); ?>">
<?php
}
add_action('product_brands_info_after', 'add_brand_link_end');
function add_brand_link_end($term){
?>
</a>
<?php
}
Make sure you have added brand url in the admin panel, please see the screenshot https://prnt.sc/_YaUhdokAQCd . Hope it will work for you.

how to show only relevant tag on post page

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"]; ?>

How to call single.php file using dynamically posts in wordpress?

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

Featured Image URL outside of Loop

I have a page on my Wordpress website called Blog, this is set to a static page and is the Blog page so it has a list of blog posts. On the blog page I have a featured image set. I want to use this featured image as a background image on the Blog page.
home.php (template for blog page):
At the top of home.php before the Loop that pulls the list of blog posts I have:
<?php
$page_id = get_queried_object_id();
if ( has_post_thumbnail( $page_id ) ) :
$image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $page_id ), 'optional-size' );
$image = $image_array[0];
else :
$image = get_template_directory_uri() . '/images/default-background.jpg';
endif;
echo $image;
?>
<div class="feature" style="background-image: url('<?php echo $image; ?>')"></div>
This works and it sets the featured image. However it seems to have set the featured image on every single page on the website to the featured image from the Blog page. Even after I changed the featured image on the About Us page it still pulls the URL for the Blog page's featured image and sets that as the featured image on the About Us page.
I have the website here: http://www.cqwebdesign.co.uk/Action-Harpenden-Physiotherapy/
As you can see by these screenshots I have set different featured images on the Blog and About page:
http://i.imgur.com/DnU8V9F.jpg
http://i.imgur.com/qshulWT.jpg
Anyone know how I can fix this?
As the home.php template affects only your Blog Page, it would be interesting how your page.php template code looks like (Notice: page.php is the default template for pages like your 'About' Page) and why the featured image isn't shown correctly on this page(s).
Try to debug or echo your id values for the Blog Page and the About Page and verify if the corresponding page id is the same as the one referred by get_queried_object_id();.
I think you're having a page.php template but just in case, if you don't have one please notice Wordpress' Template Hierarchy
Wordpress Codex:
When the static front page feature is configured properly, WordPress will not use a Custom Page Template to display the blog posts index, even if a Custom Page Template is assigned to the page designated as the "Posts page". WordPress will only use either home.php or index.php.

How to show page title in blog post of wordpress site

I want to show the page title in single post page of wordpress theme. I tried to use <?php echo get_the_title() ?> but it return the post title, not the page title.
basically I want to show MY page title, in this case "Blog" below my header area in single.php file. how do I make it?
In order to get page title you need to use WordPress API function use the code below
<?php
$post_7 = get_post($id);
$title = $post_7->post_title;
?>
In wordpress both posts and pages have ids. So same function will work to get title of either post or page.
You have to pass this parameter to get the title of the page.
For reference see this link
http://codex.wordpress.org/Function_Reference/get_post

Resources