Next/previous posts link not showing at all - php

i'm creating a new blog in wordpress
and i got a problem with index.php file
the button is not showing and i tried a lot and nothing change
this is the code in index.php
<div class="block n-p">
<?php previous_posts_link(); ?>
||
<?php next_posts_link(); ?>
</div>
<!--End block-->
any Advice please?
and thank you for the Support.

I think it should be
<?php previous_post(); ?> <?php next_post(); ?>
without the "_link"

Related

Unknown word is coming from the pages in wordpress

I am getting child pages of a specific page. below is my code.
<div class="col-sm-3 services">
<h3>SERVICES</h3>
<?php $get_subcategories = wp_list_pages(array('child_of'=>39)); ?>
<ul>
<?php foreach($get_subcategories as $subcategory){?>
<li><?php echo $subcategory->name;?></li>
<?php }?>
</ul>
</div>
Here is the output of above code.
Problem: I am getting an additional word PAGES also. which is encircled in the above image.
From where this words is coming, and how to hide this ?
It is a default from the wp_list_pages() function.
Source: https://developer.wordpress.org/reference/functions/wp_list_pages/
You need to enter your title_li
<?php $get_subcategories = wp_list_pages(array('child_of'=>39, 'title_li' => '')); ?>
Here i solved the issues of showing default title and bullet points on each list item, by following the guidelines of #Gavin & #misorude i changed the above code and now it is working fine.
<div class="col-sm-3 services">
<h3>SERVICES</h3>
<ul>
<?php $get_subpages = wp_list_pages(array('child_of'=>39,'title_li'=>'')); ?>
</ul>
</div>

How can i display footer depending on the language website?PHP

This is the code I tried but unfortunately does not work
<?php if(get_the_ID()==22) : ?>
<p class="dg-design"> website by dgdesign </p></p>
elseif(ICL_LANGUAGE_CODE=='es'){
<p class="dg-design"> websadsasite by dgdessadsadaign </p></p>
}
<?php endif; ?>
Can you tell me what is wrong please?
At the moment when I run the site does not change anything
I use a wordpress theme.
Can you give an example to show me how can I solve this problem?
Thanks in advance!
<?php if(is_page(22)){?>
<?php if(ICL_LANGUAGE_CODE=='en'){?>
<p class="dg-design"> website by
dgdesign
</p>
<?php }elseif(ICL_LANGUAGE_CODE=='es'){?>
<p class="dg-design"> websadsasite by
dgdessadsadaign </p>
<?php }?>
<?php }?>

php included navigation menu not working

I have a php page that has many includes. The whole page runs fine, but for my navigation bar, it does not open any page when I click on it. Please, what is missing here. Any help will be appreciated. many thanks
Here are my codes for the includes
<div id='cssmenu'>
<ul>
<li class='active'><span>Home</span></li>
<li><span>About Us</span></li>
<li><span>Packages</span></li>
<li><span>Partners</span></li>
<li><span>Gallery</span></li>
<li class='last'><span>Contact Us</span></li>
</ul>
</div>
And here is my main page code:
<body>
<div id="wrapper">
<div>
<img src="images/banner.png" width="940" height="200" />
</div>
<?php include('includes/nav.php'); ?>
<?php include('includes/slider.php'); ?>
<?php include('includes/nav.php'); ?>
<?php include('includes/contents.php'); ?>
<?php include('includes/sidebar.php'); ?>
<?php include('includes/footer.php'); ?>
</div> <!-- End #wrapper -->
</body>
Not sure of your file structure, but try removing the '../' on all you links
Change this:
<li class='active'><span>Home</span></li>
to this:
<li class='active'><span>Home</span></li>
Take the ../ out of your path.
When you include the nav.htm to your main page it acts as if it is in the main folder
Therefore if you use '../' it won't find it.

How to remove anchor from active navigation page using PHP?

I am sure this is a fairly simple question to answer, but I am new to PHP, so I was hoping someone could help me solve this problem.
I have a dynamic navigation menu that works really well, but I want to remove the link from the current page in the menu.
Here is my code:
<div id="navigation_menu">
<?
foreach($pagedata->menu as $menuitem){
$class = ($menuitem->uri == $requesteduri) ? 'navigation selection' : 'navigation page_select';
?>
<div id="<?=$menuitem->uri?>" class="<?=$class?>">
<img class="nav_icon" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/<?=$menuitem->uri?>.png">
<h1><?=$menuitem->title?></h1>
<h2><?=$menuitem->description?></h2>
<img class="go" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/go.png">
</div>
<?
}
?>
</div>
Any help would be greatly appreciated. Thanks!
UPDATED CODE: (this is what works for me now)
<div id="navigation_menu">
<?
foreach($pagedata->menu as $menuitem){
$class = ($menuitem->uri == $requesteduri) ? 'navigation selection' : 'navigation page_select';
?>
<div id="<?=$menuitem->uri?>" class="<?=$class?>">
<img class="nav_icon" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/<?=$menuitem->uri?>.png">
<h1>
<?php if ($menuitem->uri == $requesteduri):?>
<?=$menuitem->title;?>
<?php else: ?>
<?=$menuitem->title?>
<?php endif;?>
</h1>
<h2><?=$menuitem->description?></h2>
<img class="go" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/go.png">
</div>
<?
}
?>
</div>
I don't know what your loop is outputting, but you want to match your page name with the menuitem->uri. So you'd get your page name like.. (Put this outside the loop)
<?php echo base_name($_SERVER['REQUEST_URI']); ?>
find out what your loop is outputting (Put this in the loop):
<?php echo $menuitem->uri; ?>
Then you'd create an if statement to compare the current menuitem in the loop and the page request, this is just an example:
<h1>
<?php if (base_name($_SERVER['REQUEST_URI']) == $menuitem->uri):?>
<?=$menuitem->title?>
<?php else: ?>
<?=$menuitem->title;?>
<?php endif;?>
</h1>
Put a conditional around the anchor text to see if $menuitem->uri is equal to the current page URL, accessible from `$_SERVER['REQUEST_URI'] before outputting the anchor tags.

Drupal Block PHP

Im created a custom block, with the below code, but im having some trouble turning the Group Title into an link, that will take the user back to the group at anytime.
Below is the code ive used, I thought active turns it into a link, but perhaps im being stupid.
<div class="active"><h2><?php print $group_title; ?></h2></div>
Below is the full code:
<?php $group_title = og_get_group_context()->title; ?>
<?php $group_nid = og_get_group_context()->nid; ?>
<?php $forum_link = og_forum_get_forum_container($group_nid); ?>
<div class="active"><h2><?php print $group_title; ?></h2></div>
<div class="content"
<div class="item-list">
<ul>
<li class="user-input-link"><a title="Add a new Forum topic"href="/node/add/forum?gids[]=<?php print $group_nid; ?>">Add a new forum topic</a>
</ul>
</div>
</div>
You need to create URL for it to work.
Here is the link to API with more info: http://api.drupal.org/api/drupal/includes--common.inc/function/l/6
<div class="active"><h2><?php print l($group_title, "node/{$group_nid}"); ?></h2></div>
You need to do an anchor tag, like:
<div><h2><?php print $group_title; ?></h2></div>
I don't know how to get the url in Drupal though..

Categories