I am having issues with a custom url. I have a page with a gallery type plugin/shortcode. Now each gallery item displayed on the page, has a readmore link, linking to that gallery item post.
Now I created my own custom url variable that can be set on the gallery item post:
This was added like this on the recipe_options.php page, where you can set the various options on each gallery item post.
$recipe_url = ''; This was added like this to the recipe_options.php page:
function add_recipe_option_element(){ $recipe_price = ''; $recipe_social = ''; $sidebars = ''; $right_sidebar_recipe = ''; $left_sidebar_recipe = ''; $recipe_detail_xml = ''; $select_chef = ''; $recipe_url = ''; foreach($_REQUEST as $keys=>$values){ $$keys = $values; } global $post; $recipe_detail_xml = get_post_meta($post->ID, 'recipe_detail_xml', true); $ingredients_settings = get_post_meta($post->ID, 'ingredients_settings', true); $nutrition_settings = get_post_meta($post->ID, 'nutrition_settings', true); if($recipe_detail_xml <> ''){ $cp_recipe_xml = new DOMDocument (); $cp_recipe_xml->loadXML ( $recipe_detail_xml ); $recipe_price = find_xml_value($cp_recipe_xml->documentElement,'recipe_price'); $recipe_url = find_xml_value($cp_recipe_xml->documentElement,'recipe_url'); $recipe_social = find_xml_value($cp_recipe_xml->documentElement,'recipe_social'); $sidebars = find_xml_value($cp_recipe_xml->documentElement,'sidebars'); $left_sidebar_recipe = find_xml_value($cp_recipe_xml->documentElement,'left_sidebar_recipe'); $right_sidebar_recipe = find_xml_value($cp_recipe_xml->documentElement,'right_sidebar_recipe'); } //AND further down on the recipe_options.php page
<ul class="recipe_class"> <li class="panel-title"> <label for="recipe_url" > <?php _e('RECIPE URL', 'crunchpress'); ?> </label> </li> <li class="panel-input"> <input type="text" name="recipe_url" id="recipe_url" value="<?php if($recipe_url <> ''){echo $recipe_url;};?>" /> </li> <li class="description"><p>Please enter your url</p></li> </ul> <div class="clear"></div> The LINK
This is the part, on the same recipe_options.php page, where you set the href property for the 'read more' link:
<article class="menu-det"> <p><?php echo strip_tags(mb_substr(get_the_content(),0,$num_excerpt));?> <a class="c-link" href="<?php echo $recipe_url ;?>"><?php _e('Read M...', 'crunchpress'); ?></a></p> </article> You need to look at this part:
href="<?php echo $recipe_url ;?>" The original code was:
href="<?php echo get_permalink() ?>" Now, I cannot get this url to appear on the link on the page...I even tried using some of the existing variables like $recipe_price, but nothing works
Any ideas what I might be doing wrong?
Thanks
get_permalinkI am guessing you are trying to get the code to show up on the front end, but most of what you are talking about is back-end code. What outputs the link on the front? The disjointed nature of the way you posted the code makes it very hard to follow.