I have a website with several pages with links/buttons that should lead to a specific page.
Is there a way to link this buttons in a dynamic way, that does not include page ID?
Currently I am doing it this way, with ACF field in which I write in a page ID
<div class="projects-homepage-item">
<?php $projects_page = get_post(get_field('page_id')); ?>
<a href="<?php the_permalink($projects_page->ID); ?>" class="projects-homepage-item-img" target="_blank">
<?php the_post_thumbnail(); ?>
</a>
</div>
Is there something similar to this function that leads to blog/post page?
<div class="news-homepage-btn-wrapper">
<?php printf(__('Pogledaj sve novosti', 'femix')); ?>
</div>
Related
Looking for a simple if/else statement in Wordpress to show a code that includes a template-part IF it's on page id's 30 and 40 but don't show it on any other page.
My Code:
<div id="tg-menu" class="tab-content">
<h3>Menu</h3>
<?php get_template_part('template-parts/menus', 'lunch-menu',array('child_id' => $args['child_id'])); ?>
</div>
Also, this code would need to be targeted to the same ID's to show if they meet the 2 page id's otherwise don't show on any other pages.
<a href="#tg" target="_blank" class="button--gold btn-gold-x-sm shrink center-flex" style="margin-top: 30px">
<span class="btn_text">Menu</span>
</a>
Any help would be appreciated.
us the is_page() function and use your Id's as the parameters
<?php if ( is_page(30) || is_page(40) ): ?>
<div id="tg-menu" class="tab-content">
<h3>Menu</h3>
<?php get_template_part('template-parts/menus', 'lunch-menu', array('child_id' => $args['child_id'])); ?>
</div>
<a href="#tg" target="_blank" class="button--gold btn-gold-x-sm shrink center-flex" style="margin-top: 30px">
<span class="btn_text">Menu</span>
</a>
<?php endif;?>
I'd like to know if it's possible to open a page (id=26) at a specific position: .
At the front page i'm using this code at the php file to make the title link to the page
<a href="<?php echo get_page_link(26); ?>">
<?php if(!empty( $clean_biz_home_service_title ) ){ ?>
<h2>
<?php echo esc_html( $clean_biz_home_service_title); ?>
</h2>
</a>
Yes, you can use DOM selectors such as #maincontent. You would need to assign an ID to a section on the page and then append it to the trigger URL.
For ex: http://yourdomain.com/index.html#maincontent would take you to that div on the page.
First, in the content of that page (id=26), you need to add an id attribute to some tag, like so:
<div id="myposition">
...
</div>
Next, append #myposition after the get_page_link(26) call:
<a href="<?php echo get_page_link(26); ?>#myposition">
<?php if(!empty( $clean_biz_home_service_title ) ){ ?>
<h2>
<?php echo esc_html( $clean_biz_home_service_title); ?>
</h2>
</a>
And you are done.
<div name="position">
content
</div>
link
example:
if you click the link below you will open this page at #new-answer position
link
I am building a website and i have this issue :
I am working on a template and i did some modification. So the front page have some boxes which shows deals and buttons.
As you can see there are buttons called "See Deals"
Each box is a post so when i create a post then each box created automatically . I want that when i put a link on post then it will automatically set behind that "See Deals" button. I mean i want that this "See deal" button take the url from a link which i put in this post.
I wrote this code for boxes :
<div class="price_row_grid">
<div class="price_for_grid floatleft">
<?php theme_create_btn('no', 'price'); ?>
</div>
<div class="floatright vendor_for_grid">
<?php if ($price_meta == 'admin'): ?>
<?php $author_id = $post->post_author; ?>
<a class="admin" href="<?php echo get_author_posts_url($author_id) ?>" title="<?php the_author_meta('display_name', $author_id); ?>">
<?php echo get_avatar($author_id, '22'); ?>
</a>
<?php elseif ($price_meta == 'store'): ?>
<div class="brand_logo_small">
<?php WPSM_Postfilters::re_show_brand_tax('logo'); //show brand logo?>
</div>
<?php endif; ?>
</div>
</div>
<div class="price_row_grid">
<div class="price_for_grid floatleft">
<p class="button">Get Deal</p>
</div>
Now suppose i created a post on wordpress :
Now you can see there i put a dummy link at the end of post "google" now i want that when i put any link there then the box of this post get this link and set behind "Get Deal" button.
I have this div content in my header.php file contained in application/themes/custom_name/elements
<?php defined('C5_EXECUTE') or die("Access Denied.");
$this->inc('elements/header_top.php');
$cl_txt = $c->getAttribute('client_login_txt');
$cl_url = $c->getAttribute('client_login_url');
?>
......
<div class="login">
<a href="<?php echo $cl_url ?>" target="_blank">
<button type="button" class="btn-login"><?php echo $cl_txt ?></button>
</a>
</div>
I would like to change the link contained in the div.
Where can I do it?
There are two Page Attributes, the link URL is called Client Link URL and the link text is called Client Link Text, I was able to edit this by going to Full Sitemap and click on the page I am trying to change and select Attributes.
I am doing some WordPress theming. I have a #novelsslider div. Inside of #novels, I used this code to get the latest three posts in the "novels" category, inside of the html divs, I used some php functions to get the latest 3 posts and load the html 3 times floated to the left to build a slider:
<!-- slider -->
<div id="novelsslider" class="slider">
<? $novels = get_option('of_novels') ?>
<?php query_posts('category_name=$novels&posts_per_page=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="sliderunit">
<?php the_post_thumbnail(); ?>
<div class="novelsslidertitle">
<div class="arrow-left"></div>
<a href="<?php the_permalink(); ?>">
<img class="cross" src="<?php bloginfo('stylesheet_directory'); ?>/images/cross.png"/>
</a>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</div>
</div>
<?php endwhile;?>
<div id="novelsslidebars">
<input type="submit" value="" class="slidebars" id="novelsslidebtnleft">
<input type="submit" value="" class="slidebars" id="novelsslidebtnmiddle">
<input type="submit" value="" class="slidebars" id="novelsslidebtnright">
</div>
</div>
<!-- End novelsslider -->
ow I have some arrows.. I want them when clicked to get a set of previous 3 posts and load them, how can I do such a loop?
To achieve this you can adopt any of these methods :
1- If your posts are not in large number then you can preload them and store in some container which is hidden by default and will appear when you click the next / previous button, like a content slider, but this is a bad approach and not recommended.
2- Use AJAX to load the rest of the posts, this is a good method and will be purely dynamic. Look on the following links to have the idea:
http://wp.tutsplus.com/tutorials/getting-loopy-ajax-powered-loops-with-jquery-and-wordpress/
Wordpress - how can I fetch more posts via AJAX?